Forum: Ruby on Rails restful auth problem

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8fa0f5c2bf8ad238baa4e20cb0360ebd?d=identicon&s=25 Matt Harrison (iwasinnamuknow)
on 2008-12-17 22:11
(Received via mailing list)
Hi folks,

I have been working on a website and I used restful auth as a starting
point for the authentication.

Suddenly (I don't think I broke it but I don't know) it has started
throwing me a weird problem.

I have a view that checks to see if the user is logged in (logged_in?)
and if yes, check the user's roles (current_user.has_role?) and display
a menu accordingly.

The login check seems to return true for non-authenticated users and
thus falls over when it tries to get the roles (no method:
nil.has_role?)

I have definitely not fiddled with the restful auth libs, like
authenticated_system.rb. I have gone back and checked the svn logs to
see what else I might have broken, but I can't find a trace.

I don't know where to start tracking this problem down, I looked at the
code for logged_in? and it's so simple I don't see how it could have got
broken.

Any ideas welcomed as I'm pretty much stuck

Thanks

Matt
8fa0f5c2bf8ad238baa4e20cb0360ebd?d=identicon&s=25 Matt Harrison (iwasinnamuknow)
on 2008-12-18 00:09
(Received via mailing list)
Solved...embarrasingly.

I was looking at the wrong line...doh

The actual problem was I had used "has_role?" later on in the layout but
hadn't wrapped it with "if logged_in?".

Lets just keep quiet about this one :P
This topic is locked and can not be replied to.