Module: Card::Auth::ApiKey

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

Overview

methods for setting current account

Instance Method Summary collapse

Instance Method Details

#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 'card-mod-api_key/lib/card/auth/api_key.rb', line 30

def  api_key
   :api_key, api_key.strip
end

#signin_with(opts = {}) ⇒ Object



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

def  opts={}
  if opts[:token]
     opts[:token]
  elsif opts[:api_key]
     opts[: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 'card-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