You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
336 B
Ruby
21 lines
336 B
Ruby
11 years ago
|
class AuthCookieStrategy < ::Warden::Strategies::Base
|
||
|
|
||
|
def valid?
|
||
|
auth_token.present?
|
||
|
end
|
||
|
|
||
|
def authenticate!
|
||
|
user = User.where(auth_token: auth_token).first
|
||
|
user && success!(user)
|
||
|
end
|
||
|
|
||
|
private
|
||
|
|
||
|
def auth_token
|
||
|
request.cookies['auth_token']
|
||
|
end
|
||
|
|
||
|
end
|
||
|
|
||
|
Warden::Strategies.add(:auth_cookie, AuthCookieStrategy)
|