Class: ApiTokenStrategy

Inherits:
Warden::Strategies::Base
  • Object
show all
Defined in:
app/strategies/api_token_strategy.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



8
9
10
11
12
13
14
15
16
# File 'app/strategies/api_token_strategy.rb', line 8

def authenticate!
  user = User.find_by(api_token: api_token)

  if user
    success!(user)
  else
    fail!('Invalid email or password')
  end
end

#valid?Boolean

Returns:

  • (Boolean)


4
5
6
# File 'app/strategies/api_token_strategy.rb', line 4

def valid?
  api_token.present?
end