Class: Aid::Auth::Helper

Inherits:
Object
  • Object
show all
Defined in:
lib/aid/auth/helper.rb

Instance Method Summary collapse

Instance Method Details

#auth_managerObject

Raises:

  • (NotImplementedError)


5
6
7
# File 'lib/aid/auth/helper.rb', line 5

def auth_manager
  raise NotImplementedError
end

#authorized?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/aid/auth/helper.rb', line 9

def authorized?
  auth_manager.authorized?
end

#current_accountObject



17
18
19
20
21
# File 'lib/aid/auth/helper.rb', line 17

def 
  @current_account ||= Account.find()
rescue ActiveRecord::RecordNotFound
  raise ::Aid::Auth::Errors::Unauthorized
end

#current_account_idObject



13
14
15
# File 'lib/aid/auth/helper.rb', line 13

def 
  auth_manager.
end

#current_clientObject



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']
                        .clients.find(request.env['HTTP_X_CLIENT_ID'])
                      else
                        nil
                      end
end