Module: Card::Auth::ApiKey

Defined in:
mod/api_key/lib/card/auth/api_key.rb

Overview

methods for setting current account

Instance Method Summary collapse

Instance Method Details

#api_act?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'mod/api_key/lib/card/auth/api_key.rb', line 34

def api_act?
  Env.controller&.try(:authenticators)&.values&.compact.present?
end

#find_account_by_api_key(api_key) ⇒ +*account card?

find +*account card by +*api card

Parameters:

  • api_key (String)

Returns:

  • (+*account card, nil)


30
31
32
# File 'mod/api_key/lib/card/auth/api_key.rb', line 30

def  api_key
   :api_key, api_key.strip
end

#signin_with(token: nil, api_key: nil) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'mod/api_key/lib/card/auth/api_key.rb', line 7

def  token: nil, api_key: nil
  if token
     token
  elsif api_key
     api_key
  else
    
  end
end

#signin_with_api_key(api_key) ⇒ Object

set the current user based on api_key



18
19
20
21
22
23
24
25
# File 'mod/api_key/lib/card/auth/api_key.rb', line 18

def  api_key
   =  api_key
  unless &.authenticate_api_key api_key
    raise Card::Error::PermissionDenied, "API key authentication failed"
  end

   .left_id
end