analogue40
2010-Mar-09 09:13 UTC
Authlogic and Aegis, current_user nil problem, Guest user
Hi All,
I have set up Authlogic and Aegis for role based authorization.
Each time I check if a user has permission to do something, as it
stands now I have to check ''current_user'' isn''t empty
first, like
this:
<% if current_user and current_user.may_do_something? %>
I''d like to change it so that if the user isn''t logged in, an
empty
user is created with the role of ''guest'', an like explained in
this
post:
http://www.agileweboperations.com/role-based-permissions-for-your-ruby-on-rails-application/#comment-1657
@current_user = User.find_by_id(session["user_id"]) ||
User.new(:role_name => "guest")
The problem is that I have no idea how to implement this in Authlogic,
the application controller has these two methods, can anyone help out?
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session &&
current_user_session.user
end
Thanks in advance!
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.