Rails Gem在注册时激活选定的用户?

时间:2013-09-26 15:32:15

标签: ruby-on-rails authentication devise rubygems omniauth

我正在开发一个门户网站,并且想要实现一个注册机制,在这个机制中,具有某些特质的人将被激活以使用门户网站。

以下是我要找的两件事:

    1]
    As a simple example, anyone who went to stanford and berkley could use it (So email should have @stanford.edu OR Linkedin Profile should indicated similar etc) . This could be extended to other similar constraints. 

    For now, its fine if I have to manually visit LinkedIn page, or exchange some emails before the approval is done.  

    2] 
    Some users with a pre-generated code are allowed to signup irrespective of above constraints. Eg a Gift card that has a membership pre-approved. 

3] 
This is not important , but there could be some pages/routes that could be available to everyone without approval. 

我正在寻找Gem来执行此任务或任何有关如何快速优雅地实施此任务的建议。如果解决方案可以扩展到10K用户,那就很好。

谢谢!

P.S: 目前我正在使用Devise和Omni-auth来支持身份验证,因此如果新解决方案可以支持这些更好,那就更好了

1 个答案:

答案 0 :(得分:0)

按照Devise Wiki Page on Approvals进行初步设置审批流程,当新用户通过AdminMailer邮件进行注册时,会通知您(或您选择的任何人)。

然后,通过使用before_create回调,您可以检查自定义验证,即:

def approved_via_linked_in?
    # perform logic here...
end

并且,您可以在电子邮件中设置一个条件,该条件会从您的AdminMailer发送,只有在用户尚未通过您的自定义验证时才会发送。