简体   繁体   中英

How to allow sign in with devise if user is already authenticated?

There's an App which creates a new user when you first time open the site (if you don't have a cookie). Also you can sign in as different user. The problem is Devise doesn't allow to sign in as already authenticated user. Even if I override require_no_authentication in SessionsController warden still remembers the user through session.

I do aware about guest user pattern but there's no guest user. The app is intended to create real user accounts and allow to sign in as another users.

So the question is should I create new Warden strategy and if so, what checks shall I do there? Or there's another way?

Just reset the session in the desired action. You can just make the first line be reset_session , or make it a before filter, like so:

before_filter :deauthorize_user, only: [ :some_action ]

def deauthorize_user
  reset_session
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM