What is the best way to ban/block users with Devise for Rails?

前端 未结 3 684
悲&欢浪女
悲&欢浪女 2020-12-24 15:07

I\'m using Devise for authentication in my rails app and I\'d like to be able to block certain accounts and prevent users from reregistering with a blocked email. I\'m just

3条回答
  •  星月不相逢
    2020-12-24 16:01

    I would do it like this:

    def after_sign_in_path_for(resource)
      if resource.is_a?(User) && resource.banned?
        sign_out resource
        banned_user_path
      else
       super
      end
    end
    

提交回复
热议问题