sorcery icon indicating copy to clipboard operation
sorcery copied to clipboard

Why do I have to call `authenticates_with_sorcery!`?

Open arnvald opened this issue 10 years ago • 1 comments

Recently I've started wondering why I need to set the relation between the Sorcery and User class twice. First time, when I set user_class attribute in initializer, and second time, when I call authenticates_with_sorcery! in model.

Although potential issues are rare, rather easy to detect and fix, this just does not feel right to me and I think we should improve the design here.

I think we should do following:

  1. Deprecate and later remove user_class setting from initializer
  2. authenticates_with_sorcery! should set the class it's called in as a user_class variable for config (we could rename it to model_class to avoid confusion or something)
  3. Config class should raise an error if authenticates_with_sorcery! is called twice (for users who try to have separate user classes)

arnvald avatar Jun 27 '14 04:06 arnvald

  1. Deprecate and later remove user_class setting from initializer

I fully agreed with this. user_class is bad when you have, for example, users and admins - two different models, but both needs authentification.

bdandy avatar Jun 11 '15 13:06 bdandy