Skip to content

Instantly share code, notes, and snippets.

@ouranos
Created May 25, 2015 09:19
Show Gist options
  • Save ouranos/f1711e61989c6c955063 to your computer and use it in GitHub Desktop.
Save ouranos/f1711e61989c6c955063 to your computer and use it in GitHub Desktop.
# lib/strategies/authentication_token_strategy.rb
class AuthenticationTokenStrategy < ::Warden::Strategies::Base
def valid?
authentication_token
end
def authenticate!
user = User.find_by_authentication_token(authentication_token)
user.nil? ? fail!('strategies.authentication_token.failed') : success!(user)
end
private
def authentication_token
params['authentication_token']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment