summaryrefslogtreecommitdiff
path: root/users/app/controllers/controller_extension/token_authentication.rb
blob: cd5c074ac4e5e567e0ebd4fa1f25da7a6226b30d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module ControllerExtension::TokenAuthentication
  extend ActiveSupport::Concern

  def token
    @token ||= authenticate_with_http_token do |token_id, options|
      Token.find(token_id)
    end
  end

  def token_authenticate
    token.authenticate if token
  end

  def logout
    super
    clear_token
  end

  def clear_token
    token.destroy if token
  end
end