Sha256: 55694d1f7e5c695c076d2a0693f7748168ddc4bb57232ab61a58b4ea9fc025af
Contents?: true
Size: 888 Bytes
Versions: 5
Compression:
Stored size: 888 Bytes
Contents
require "jwt" class Card module Auth # methods for setting current account module ApiKey def signin_with opts={} if opts[:token] signin_with_token opts[:token] elsif opts[:api_key] signin_with_api_key opts[:api_key] else signin_with_session end end # set the current user based on api_key def signin_with_api_key api_key account = find_account_by_api_key api_key unless account&.authenticate_api_key api_key raise Card::Error::PermissionDenied, "API key authentication failed" end signin account.left_id end # find +\*account card by +\*api card # @param api_key [String] # @return [+*account card, nil] def find_account_by_api_key api_key find_account_by :api_key, api_key.strip end end end end
Version data entries
5 entries across 5 versions & 1 rubygems