diff options
author | Azul <azul@leap.se> | 2014-02-06 09:47:37 +0100 |
---|---|---|
committer | Azul <azul@leap.se> | 2014-02-10 14:26:30 +0100 |
commit | e1243d02953b4012d6bb216efc9b0606809ab4bb (patch) | |
tree | b0c9426d8d940a652d41aed8f3137bad1ca58800 | |
parent | bcdde2f6bfb4ed3a1535bd2e50ab47529a9141e2 (diff) |
minor: refactor token auth a bit
-rw-r--r-- | users/app/controllers/controller_extension/token_authentication.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/users/app/controllers/controller_extension/token_authentication.rb b/users/app/controllers/controller_extension/token_authentication.rb index 530294a..cd5c074 100644 --- a/users/app/controllers/controller_extension/token_authentication.rb +++ b/users/app/controllers/controller_extension/token_authentication.rb @@ -1,11 +1,14 @@ module ControllerExtension::TokenAuthentication extend ActiveSupport::Concern - def token_authenticate - authenticate_with_http_token do |token_id, options| - @token = Token.find(token_id) + def token + @token ||= authenticate_with_http_token do |token_id, options| + Token.find(token_id) end - @token.authenticate if @token + end + + def token_authenticate + token.authenticate if token end def logout @@ -14,10 +17,7 @@ module ControllerExtension::TokenAuthentication end def clear_token - authenticate_with_http_token do |token_id, options| - @token = Token.find(token_id) - @token.destroy if @token - end + token.destroy if token end end |