Undefined Method Refresh Token in AuthenticatedSystem

On my site, I have a series of protected tabs and a series of public
tabs. Depending on the level of authentication, the tabs are viewable
to specific groups. I’ve encountered an old issue and I feel it’s time
to correct this problem. I’ve put it off for sometime now, and while
that’s not the best thing to do, I had a simple workaround in place.

The issue starts in the application controller through these lines here:

def get_user_tabs
if logged_in? && User.find(current_user).admin?
@tabs = Page.find_main
else
@tabs = Page.find_main_public
end
end

I use AuthenticatedSystem with activation for my site. If I login with
a specific admin group and check “remember me”, each subsequent visit
for the next week I’ll automatically be logged in.

However, the very first time I hit the website, I’ll receive the
following error:

NoMethodError (undefined method `refresh_token’ for #User:0x5ffe238)

The refresh_token in AuthenticatedSystem usually corresponds to the
remember_me token setting. I believe what’s happening is that the token
isn’t being refreshed until after the second page click on the site
occurs. Therefore, it will error out as per above.

I’ve gotten around this issue by doing the following rescue:

def get_user_tabs
begin
if logged_in? && User.find(current_user).admin?
@tabs = Page.find_main
else
@tabs = Page.find_main_public
end
rescue
logger.error(“undefined method `refresh_token”)
@tabs = Page.find_main_public
end
end

However, as you can see, I should not have to place a rescue in and the
corrupted data should not be allowed to reach as far as the rescue,
IMHO. I’ve searched many areas in AuthenticatedSystem from issues, to
wiki, etc. but can’t seem to pinpoint where this issue might be stemming
from. Perhaps it’s as simple as how I find the current user?

Any help on this matter would be appreciated.

Thanks.

As a further diagraming mode for this problem above, using the rescue
workaround that I have in place:

First visit to the site with remember_me active as an administrator:

[publictab1] [publictab2] [publictab3] [publictab4]

Tabs correspond to menu buttons…

The login shows that I’m logged in as an administrator. However, I only
see public tabs (menu buttons).

On the very next click (on any public tab), I see the following:

[publictab1] [publictab2] [publictab3] [PRIVATETAB1] [PRIVATETAB2]
[publictab4]

So, what is happening is the first visit to the site causes the rescue
to force display public tabs only and then I have to click a tab in
order to see the private tabs as well as the public tabs. I believe it
might have something to do with the way the remember me token is
refreshed…

I waited a couple of days before bumping this. I could still use some
help on this. If any further information is needed, please let me know.

Thanks.