白名单与色器件 [英] Whitelisting with devise

查看:171
本文介绍了白名单与色器件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的设计在我的Rails应用程序来管理用户认证。设计真是太棒了点。

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?

先谢谢了。

推荐答案

你可以做的是建立自己的注册控制器和扩展设备一个像:

What you can do is create your own registrations controller and extend the device one like:

class MyRegistrationController < Devise::RegistrationsController
  def create
    # do your checks
    super
  end
end

请参见:<一href=\"https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb\">https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb
和:<一href=\"https://github.com/plataformatec/devise/wiki/How-to:-Customize-routes-to-user-registration-pages\">https://github.com/plataformatec/devise/wiki/How-to:-Customize-routes-to-user-registration-pages

祝你好运!

这篇关于白名单与色器件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆