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:
@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!