简体   繁体   English

RoR Devise使用电子邮件或用户名注册

[英]RoR Devise sign up with either email or username

I have a RoR apps which uses Devise for user registrations and session management. 我有一个使用Devise进行用户注册和会话管理的RoR应用程序。 As of now the users can signup using email and I use :confirmable in devise so that a confirmation email is sent and user account will be activated. 到目前为止,用户可以使用电子邮件进行注册,而我在设计中使用:confirmable以便发送确认电子邮件并激活用户帐户。 But now I want to add a option to user to register either with email or username so that i have to confirm if he uses email and no confirmation is required if he is not providing email.. 但是现在我想为用户添加一个选项,以使用电子邮件或用户名注册,以便我必须确认他是否使用电子邮件,并且如果他不提供电子邮件,则无需确认。

Can i achieve this using devise..? 我可以使用dev ..来实现吗?

Thanks in advance. 提前致谢。

Check out the bottom of this wiki page: 请查看此Wiki页面的底部:

https://github.com/plataformatec/devise/wiki/How-To:-Add-:confirmable-to-Users https://github.com/plataformatec/devise/wiki/操作方法:-添加-:confirmable-to-Users

You should be able to do something like this: 您应该能够执行以下操作:

protected
def confirmation_required?
  # Insert custom logic about confirmation only if a user has an email
end

Place this in your User.rb 将此放置在您的User.rb

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM