diff options
author | jessib <jessib@riseup.net> | 2013-08-27 11:22:52 -0700 |
---|---|---|
committer | jessib <jessib@riseup.net> | 2013-08-27 11:22:52 -0700 |
commit | e481b8cbc05a858674a59ef36d695973622f6b3a (patch) | |
tree | 8a20143ce831d71076a8c3913664b3a67742ed6b /users/app/controllers/controller_extension/token_authentication.rb | |
parent | 441db4736e0cd003caf9c8f7b3fbdb1ffa72b969 (diff) | |
parent | fdf9c5f9ea605020ea371de8e221efe8e5d5ba32 (diff) |
Merge pull request #72 from azul/feature/token-based-auth
Feature: Token based auth
Diffstat (limited to 'users/app/controllers/controller_extension/token_authentication.rb')
-rw-r--r-- | users/app/controllers/controller_extension/token_authentication.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/users/app/controllers/controller_extension/token_authentication.rb b/users/app/controllers/controller_extension/token_authentication.rb new file mode 100644 index 0000000..3e2816d --- /dev/null +++ b/users/app/controllers/controller_extension/token_authentication.rb @@ -0,0 +1,23 @@ +module ControllerExtension::TokenAuthentication + extend ActiveSupport::Concern + + def token_authenticate + authenticate_with_http_token do |token_id, options| + @token = Token.find(token_id) + end + @token.user if @token + end + + def logout + super + clear_token + end + + def clear_token + authenticate_with_http_token do |token_id, options| + @token = Token.find(token_id) + @token.destroy if @token + end + end +end + |