且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在允许用户使用devise(rails)登录之前,检查用户是否处于活动状态

更新时间:2023-09-28 21:12:58

将这两种方法添加到用户模型中,设计应自动接收它们 - 您不应该需要扩展 Devise :: SessionsController

Add these two methods to your user model, devise should pick them up automatically - you should NOT need to extend Devise::SessionsController

def active_for_authentication?
  super && self.your_method_for_checking_active # i.e. super && self.is_active
end

def inactive_message
  "Sorry, this account has been deactivated."
end