2011-02-05 07:33:34 -08:00
|
|
|
require 'devise'
|
2010-10-18 14:58:45 -07:00
|
|
|
|
|
|
|
module Openneo
|
|
|
|
module Auth
|
2010-11-13 16:42:56 -08:00
|
|
|
module Strategies
|
2011-02-05 07:33:34 -08:00
|
|
|
class Token < Devise::Strategies::Authenticatable
|
2010-11-13 16:42:56 -08:00
|
|
|
def valid?
|
|
|
|
session && session[:session_id]
|
|
|
|
end
|
|
|
|
|
|
|
|
def authenticate!
|
|
|
|
begin
|
|
|
|
auth_session = Session.find session[:session_id]
|
|
|
|
rescue Session::NotFound => e
|
2011-02-05 07:33:34 -08:00
|
|
|
pass
|
2010-11-13 16:42:56 -08:00
|
|
|
else
|
|
|
|
auth_session.destroy!
|
|
|
|
success! auth_session.user
|
|
|
|
end
|
|
|
|
end
|
2011-02-05 07:33:34 -08:00
|
|
|
|
|
|
|
def remember_me?
|
|
|
|
true
|
|
|
|
end
|
2010-11-05 13:32:00 -07:00
|
|
|
end
|
2010-10-18 14:58:45 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|