Class: Aid::Auth::Helper
- Inherits:
-
Object
- Object
- Aid::Auth::Helper
- Defined in:
- lib/aid/auth/helper.rb
Instance Method Summary collapse
- #auth_manager ⇒ Object
- #authorized? ⇒ Boolean
- #current_account ⇒ Object
- #current_account_id ⇒ Object
- #current_client ⇒ Object
Instance Method Details
#auth_manager ⇒ Object
5 6 7 |
# File 'lib/aid/auth/helper.rb', line 5 def auth_manager raise NotImplementedError end |
#authorized? ⇒ Boolean
9 10 11 |
# File 'lib/aid/auth/helper.rb', line 9 def auth_manager. end |
#current_account ⇒ Object
17 18 19 20 21 |
# File 'lib/aid/auth/helper.rb', line 17 def current_account @current_account ||= Account.find(current_account_id) rescue ActiveRecord::RecordNotFound raise ::Aid::Auth::Errors::Unauthorized end |
#current_account_id ⇒ Object
13 14 15 |
# File 'lib/aid/auth/helper.rb', line 13 def current_account_id auth_manager.current_account_id end |
#current_client ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/aid/auth/helper.rb', line 23 def current_client @current_client ||= if params[:client_id] Client.find(params[:client_id]) elsif request.env['HTTP_X_CLIENT_ID'] current_account.clients.find(request.env['HTTP_X_CLIENT_ID']) else nil end end |