2010-10-18 14:58:45 -07:00
|
|
|
require 'warden'
|
|
|
|
|
|
|
|
module Openneo
|
|
|
|
module Auth
|
|
|
|
class Strategy < Warden::Strategies::Base
|
2010-11-05 13:32:00 -07:00
|
|
|
def valid?
|
|
|
|
session && session[:session_id]
|
|
|
|
end
|
|
|
|
|
2010-10-18 14:58:45 -07:00
|
|
|
def authenticate!
|
|
|
|
begin
|
|
|
|
auth_session = Session.find session[:session_id]
|
|
|
|
rescue Session::NotFound => e
|
|
|
|
fail! e.message
|
|
|
|
else
|
|
|
|
auth_session.destroy!
|
|
|
|
success! auth_session.user
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|