asciinema.org/app/strategies/auth_cookie_strategy.rb

21 lines
327 B
Ruby
Raw Normal View History

2014-02-20 22:00:44 +00:00
class AuthCookieStrategy < ::Warden::Strategies::Base
def valid?
auth_token.present?
end
def authenticate!
2014-02-20 22:14:36 +00:00
user = User.for_auth_token(auth_token)
2014-02-20 22:00:44 +00:00
user && success!(user)
end
private
def auth_token
request.cookies['auth_token']
end
end
Warden::Strategies.add(:auth_cookie, AuthCookieStrategy)