我正在尝试将用户重定向到他们登录的最后一页(使用模式) - 这是有效的。
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,我将如何将它们重定向到新的/ path?
答案 0 :(得分:1)
我认为有两种方法可以解决这个问题: