summaryrefslogtreecommitdiff
path: root/users
diff options
context:
space:
mode:
authorAzul <azul@leap.se>2014-02-06 09:47:37 +0100
committerAzul <azul@leap.se>2014-02-10 14:26:30 +0100
commite1243d02953b4012d6bb216efc9b0606809ab4bb (patch)
treeb0c9426d8d940a652d41aed8f3137bad1ca58800 /users
parentbcdde2f6bfb4ed3a1535bd2e50ab47529a9141e2 (diff)
minor: refactor token auth a bit
Diffstat (limited to 'users')
-rw-r--r--users/app/controllers/controller_extension/token_authentication.rb16
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