我的登录功能有问题。
- 当用户单击注销链接时,一切正常,会话被破坏,用户可以以其他用户身份登录。
如果当前登录的用户关闭浏览器并返回登录页面,或者如果用户只是按下登录页面的后退按钮并尝试以其他用户身份登录,则用户将被定向到之前登录的用户到该特定浏览器上的应用程序。
这不是想要的功能。我想让用户能够登录到他们想要的任何帐户,无论用户是返回登录页面,还是关闭窗口并返回登录页面。我尝试了 6 种不同的解决方案,但都没有奏效。似乎无论我对代码进行什么更改,登录功能总是从 session[:warden.user.person.key] 哈希中提取用户 ID 并使用它来登录,无论登录文本字段中输入了什么。我试图控制这个过程,但每次尝试都失败了。
我的想法已经用完了,需要一些帮助,因为这被认为是我们系统中的一个安全漏洞。
请让我知道您还想看到什么代码。我给你会话控制器代码和我的路由。
class SessionsController Devise::SessionsController
def new
session["devise.omniauth_data"]=nil
session[:last_registration_role]=nil
super
end
def create
if params['person']['remember_me'] == '1'
cookies.signed['rem'] = {
:value => params['person']['email'],
:expires => 1.year.from_now,
:httponly => true
}
end
super
end
def destroy
session["devise.omniauth_data"]=nil
session[:last_registration_role]=nil
super
reset_session
end
end
路线
new_person_session GET /people/sign_in(.:format) {:action=>"new", :controller=>"sessions"}
person_session POST /people/sign_in(.:format) {:action=>"create", :controller=>"sessions"}
destroy_person_session GET /people/sign_out(.:format) {:action=>"destroy", :controller=>"sessions"}
person_password POST /people/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_person_password GET /people/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_person_password GET /people/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /people/password(.:format) {:action=>"update", :controller=>"devise/passwords"}