diff options
author | azul <azul@riseup.net> | 2014-04-25 12:15:37 +0200 |
---|---|---|
committer | azul <azul@riseup.net> | 2014-04-25 12:15:37 +0200 |
commit | 76ad25ba0ee344f185f8e8cdfe066685cd3b0447 (patch) | |
tree | d8122b5b5144c917f5e1924c1428a3a871e94149 /app/controllers/controller_extension/authentication.rb | |
parent | 2b6200f508ddb8e1c8a76fd3778881c39d787d8d (diff) | |
parent | be81b7430e0a2046125be7c3a4b01b8725f4afe6 (diff) |
Merge pull request #148 from azul/feature/api-quota-support
Feature/api quota support + current_user null pattern
Diffstat (limited to 'app/controllers/controller_extension/authentication.rb')
-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..1f73f38 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 || anonymous 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 anonymous + AnonymousUser.new + end end |