【发布时间】:2011-02-07 19:45:30
【问题描述】:
我正在尝试将用户重定向到他们登录的最后一个页面(使用模式) - 这是有效的。
if user
# Protects against session fixation attacks, causes request forgery
# protection if user resubmits an earlier form using back
# button. Uncomment if you understand the tradeoffs.
# reset_session
self.current_user = user
new_cookie_flag = (params[:remember_me] == "1")
handle_remember_cookie! new_cookie_flag
format.html {
if @invitation.try(:invitee_email) == user.email
redirect_to(edit_invitation_path(@invitation))
else
begin
# loop check
if session[:last_back] != request.env['HTTP_REFERER']
redirect_to(:back)
session[:last_back] = request.env['HTTP_REFERER']
else
# raise on error
raise ActionController::RedirectBackError
end
rescue ActionController::RedirectBackError
# fallback on loop or other :back error
redirect_to(:action => :index)
end
end
如果用户登录失败 - 他们将被重定向到 session/new 的登录页面。
我不希望他们在成功登录后返回此页面,那么如果他们恰好来自 session/new,我将如何将他们重定向到新/路径?
【问题讨论】: