diff options
author | Azul <azul@leap.se> | 2014-04-17 12:06:38 +0200 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-04-17 12:07:13 +0200 |
commit | 614745c84cab37dd03f2bd8f06160fd01c7fabdb (patch) | |
tree | 4f77bf89513949a99bd3821c856454e3e933d838 /app/controllers/controller_extension | |
parent | 8cc5ba134f6c5a1a06d91407aa78b962545c54ac (diff) |
UnauthenticatedUser as current_user
this still allows us to do current_user.service_level.
Have not gone through the rest of the code yet.
Only made sure logged_in? now tests for is_a? User instead of !!current_user
Diffstat (limited to 'app/controllers/controller_extension')
-rw-r--r-- | app/controllers/controller_extension/authentication.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/app/controllers/controller_extension/authentication.rb b/app/controllers/controller_extension/authentication.rb index 03d3989..2bc0aee 100644 --- a/app/controllers/controller_extension/authentication.rb +++ b/app/controllers/controller_extension/authentication.rb @@ -8,11 +8,11 @@ module ControllerExtension::Authentication end def current_user - @current_user ||= token_authenticate || warden.user + @current_user ||= token_authenticate || warden.user || unauthenticated end def logged_in? - !!current_user + current_user.is_a? User end def require_login @@ -42,7 +42,7 @@ module ControllerExtension::Authentication end def admin? - current_user && current_user.is_admin? + current_user.is_admin? end def require_admin @@ -72,4 +72,10 @@ module ControllerExtension::Authentication request.env['warden.options'] && request.env['warden.options'][:attempted_path] end + + protected + + def unauthenticated + UnauthenticatedUser.new + end end |