Greetings,
I’m working with the salted hash login generator. Is there a way to
post a flash message if the user isnt authenticated for a section of my
site and has to login? If so, where should I implement it?
To understand what I am talking about, try and visit a Basecamp page
without being authenticated. It posts a notice flash telling you to
login. If you just directly visit the login page, however, there is no
flash.
Thanks for the help.
I don’t know how this logingenerator works, but:
there should be a before_filter somewhere, this executes a method before
each request. It could be in app/controllers/application_controller.rb.
In this before_filter there should be something like:
def authenticate
if {valid_login}
true
else
redirect_to :controller => ‘login’
false
end
end
You can insert the flash here:
def authenticate
if {valid_login}
true
else
flash[:notice] = ‘Not logged in’
redirect_to :controller => ‘login’
false
end
end