本文介绍了使用 Devise for Rails 禁止/阻止用户的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Rails 应用中使用 Devise 进行身份验证,我希望能够阻止某些帐户并防止用户使用被阻止的电子邮件重新注册.我只是不确定最好的方法是什么.
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 not sure what the best way is to go about it.
我的第一个想法是覆盖会话和注册控制器以检查具有阻塞位的用户的模型,但我觉得可能有更优雅的方法.
My first thought was to override the sessions and registrations controllers to check the model for a user with a blocked bit, but I have a feeling there might be a more elegant way.
推荐答案我会这样做:
def after_sign_in_path_for(resource) if resource.is_a?(User) && resource.banned? sign_out resource banned_user_path else super end end更多推荐
使用 Devise for Rails 禁止/阻止用户的最佳方法是什么?
发布评论