When Authlogic::Session::Base#find returns nil

54 views
Skip to first unread message

Mel Riffe

unread,
Sep 7, 2011, 12:05:01 PM9/7/11
to Authlogic
Greetings All,

First: Thanks Ben for AuthLogic - wonderful tool that makes
authentication easy to deal with.

Second, I would like to better understand under what conditions
Authlogic::Session::Base#find (or
Authlogic::Session::Base#find_record) returns nil.

For reasons beyond my control I'm using AuthLogic 1.4.3 with a Rails
2.2.2 application. I'm witnessing a scenario that I'm having
difficulty explaining. Actually, witnessing is too strong a
description; what's been reported to me and what I've seen in the
application logs; I have no clue as to the actions of the end-user.

Because I spent yesterday looking through the code my descriptions may
be biased. However, to me, it appears AuthLogic 'forgets' someone is
logged in. I have the following code snippet in a before_filter:

message = (current_user_session && current_user_session.stale?) ? "You
have been idle for too long.\nPlease log back into the application." :
"You are not authorized\nto perform that action."

When the message is "You are not authorized...", current_user_session
is nil. current_user_session is nil because UserSession.find returns
nil (UserSession extends Authlogic::Session::Base).

So, I would like to better understand under what conditions #find (or
#find_record) returns nil.

Thank you, in advance, for the answers.

--Mel
Reply all
Reply to author
Forward
0 new messages