什么是禁止/块用户制定了对Rails的最佳方式? [英] What is the best way to ban/block users with Devise for Rails?
本文介绍了什么是禁止/块用户制定了对Rails的最佳方式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的Rails应用程序中使用设计验证,我希望能够从一个阻止电子邮件重新注册阻止某些账户和prevent用户。我只是不知道最好的方法就是去了解它是什么。
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
这篇关于什么是禁止/块用户制定了对Rails的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文