简体   繁体   中英

Allow just that user actived sign_in - Devise

I'm using devise for authentication and have a activated:boolean on users table.
How can I only allow the activated users to sign in? And show the flash message:

Login successful for users activated and Login denied for users non-activated / deactivated users

Thanks!

To prevent deactivated users from signing in, override active_for_authentication? on your User model:

def active_for_authentication?
  super && activated
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