Clearance will save your current location if you try to access a restricted area, and will forward you to the same place after authentication. Nevertheless, if you put a "Login" link in your pages, your users will be redirected to "/", which is not always what we want. To avoid this, we will use a param to return where we want (this is usually in your app layout) :
Now we have a :return_to param with the correct URI, let's handle this in our session controller :
link_to t(:login), new_session_url(:return_to => request.request_uri)
before_filter :set_return_to, :only => :new
def set_return_to
session[:return_to] = params[:return_to] if params[:return_to]
end
Clearance is using this session var to handle the returning URI.
Now, if you're not on the home page, click on "login", enter your email / password, you will be redirected to the previous page, being identified.
1 comments:
wait to your answer.
ykan hdd
Post a Comment