How to use "username or email address" to log in?

I found a way to configure the application to use a login name instead of an email address.
But actually I want to use a combination: -

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

So how to achieve this?

In fact, we need to reconfigure the gem configuration to support this.
so far I know that modifying the /config/initializers/devise.rb file as

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

actually allow login using username instead of email.
But can I do something like: -

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

Thus, we can use the username or email address as an authentication key at runtime depending on the input provided by the user. Thanks in advance.

+4
source share
3 answers

Take a look there: https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address (updated url)

It explains how to allow users to log in using their username or email address.

+14
source

how about filtering by username or email if there is @ and a. which will be features for email.

+3
source

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

but don't forget to change: authentication_keys => [: username] in the model development or in devise.rb, as suggested in the manual on: authentication_keys => [: login], to make it work

Hello

0
source

All Articles