blob: 6e0a6ce9a78954caecb7ef1de8bab8958800d9ab (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 | 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_authenticated ||= token.authenticate if token
  end
  def require_token
    access_denied unless token_authenticate
  end
  def logout
    super
    clear_token
  end
  def clear_token
    token.destroy if token
  end
end
 |