i built my own login system, but unfortunately, i am having problems
(ie, can’t really figure out how) to redirect a person back to the page
he was requesting before logging in…say, as the admin i want to edit a
certain message/logo, whatever, so i click on it, and i get redirected
to my login page. after the admin logs in, he gets redirected to the
homepage - i couldn’t figure out how to redirect to the page he
requested…
my loggin system is this:
APPLICATION CONTROLLER:
def secure
redirect_to :controller => ‘login’ unless @session[:admin] == 1
end
in my LOGIN CONTROLLER:
def authenticate
pswd = [ ‘shai’, ‘octava’]
@input = [ “#{params[:user][:name]}”, “#{params[:user][:password]}” ]
if pswd == @input
@session[:admin] = 1
flash[:notice] = ‘successful entry.’
redirect_to :controller => ‘messages’ ####THIS IS WHAT I NEED TO
FIX
else
@session[:admin] = 0
flash[:notice] = ‘× ×ª×?× ×?× ×©×?×?×?×?×, ×× × × ×¡×? ×©× ×?ת.’
redirect_to :action => ‘login’
end
end
(i put the secure method in any action i wish to protect, and walla!,
everythings good)(except the redirecting issue)
i know the answer should be something like @session[:url_path] = xyz,
and then redirect in the authenticate action to @session[:url_path], but
the problem is, i’m not really sure what the xyz part is (that stores
the current url the person is on) and i aint really sure what the
correct syntax for doing this is…
if anyone has an answer, clue, or just plain sympathy, i’ll be ready;
thanks.
hola,
shai
octava