代码之家  ›  专栏  ›  技术社区  ›  Hemanth

如何利用“用户名或电子邮件”登录设备?

  •  5
  • Hemanth  · 技术社区  · 15 年前


    但实际上我想用组合词:-

    Enter username or Email:   <text-box>
    Enter your password    :   <text-box>  
    

    实际上,我们需要修改devieve gem的配置来支持这一点。
    现在我知道修改“/config/initializers/devieve.rb”文件为

    config.authentication_keys = [ :username ] (edited from email to username.)  
    

    实际上可以使用用户名而不是emailid登录。
    但我能做点什么吗-

    config.authentication_keys = [ :username | :email] in the "config/initializers/devise.rb" file.  
    


    提前谢谢。

    3 回复  |  直到 15 年前
        2
  •  3
  •   steveoh    15 年前

    如果用户名或电子邮件中有一个@和一个,那么对其进行过滤怎么样。这将是电子邮件的特点。

        3
  •  0
  •   Gideon Kitili    11 年前

    https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address

    但请记住按照“验证密钥”指南的建议,在“设计模型”或“设计rb”更改:authentication\u keys=>[:username]以使其正常工作

    当做