使用设备列入白名单
我正在使用 devise 来管理 Rails 应用程序中的用户身份验证。 Devise 确实非常适合这一点。
但是,我对我的应用程序有一个特殊要求:用户必须先列入白名单,然后才能注册为用户。
因此,有一个管理员创建允许的电子邮件列表。用户使用电子邮件注册,如果该电子邮件在白名单表中,则他将被注册。但是,如果该邮件不在白名单中,则应中止注册,并显示“您尚未收到邀请”之类的消息。
你知道如何用设计来解决这个问题吗?
提前致谢。
I am using devise to manage user authentication in my rails app. Devise is really great for that.
However I have a special requirement for my application: A user must be whitelisted before he can register as a User.
So there is a admin which creates a list of allowed emails. A user registers with a email and if the email is in the whitelist table he will be registered. If however, the mail is not in the whitelist, the registration should be aborted with a message like "You are not yet invited".
Do you have an idea how that could be solved with devise?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我只会使用模型验证。我假设你的 User 类有 devise 方法
I would just use model validation. I'm assuming your User class has the devise method
您可以做的是创建自己的注册控制器并扩展设备,例如:
请参阅: https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb
并且: https://github.com/plataformatec/devise /wiki/How-to:-自定义用户注册页面的路由
祝你好运!
What you can do is create your own registrations controller and extend the device one like:
see: https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb
And: https://github.com/plataformatec/devise/wiki/How-to:-Customize-routes-to-user-registration-pages
Good luck!
我确实按照建议创建了自己的控制器:
我将其放置在
app/users/registrations_controller.rb
中。然后我必须将设备注册视图复制到 app/views/users/registrations 中,因为未使用默认视图。现在正在运行,感谢您的帮助
I did create my own controller as suggested:
I placed it in
app/users/registrations_controller.rb
. Then I had to copy the devise registration views intoapp/views/users/registrations
because the default views were not used.It is working now, thanks for your help