NoamB / sorcery

Magical authentication for Rails 3 & 4
MIT License
2.31k stars 386 forks source link

"current_user" prevents proper usage of domain language #552

Closed Trevoke closed 10 years ago

Trevoke commented 10 years ago

It would be great if you could set the sorcery model to, say, "SoccerFan" (What? The World Cup just started!) and if the current method were to also be available as "current_soccer_fan".

Forcing "current_user" creates a schism in the code where the domain language disappears.

arnvald commented 10 years ago

I'm not sure about such a feature. Maybe because I'm personally against using domain name for user class (I prefer having User class for login, session etc. and SoccerFan or sth else for profile information). Anyway, I think we could merge it if someone implements it, but it must be defined as an alias for current_user - internally we should still use current_user.

On the other hand, you need just one line of code to do it in your app:

class ApplicationController < ActionController::Base`
  alias :current_soccer_fan :current_user
end

So you don't even need changes in Sorcery to have it done easily.

kirs commented 10 years ago

I agree with @arnvald.