I found a way to customize devise to use username to login instead of email address.
But actually I want to use combination :-
Enter username or Email: <text-box>
Enter your password : <text-box>
So how to achieve this ?
Actually we need to modify devise gem's configuration to support this.
for now I know that modifying the "/config/initializers/devise.rb" file as
config.authentication_keys = [ :username ] (edited from email to username.)
would actually enable logging in using username instead of emailid.
But can I do some thing like:-
config.authentication_keys = [ :username | :email] in the "config/initializers/devise.rb" file.
So that we devise can take username or email as authentication key at runtime depending on the input provided by user.
Thanks in advance .
Email addresses are useful as users should already remember then and they don't have to think about anything. This is useful if you don't have a "username" on your app. Example: Paypal or Dropbox, where no user name is needed to use these apps and the email is the best way to connect with other people.
Devise is a well known solution for authentication in Rails applications. It's full featured (it not only adds authentication but also password recovery, email changing, session timeout, locking, ip tracking, etc.) and can be expanded to add even more (like JWT authentication).
Look at there : https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-sign-in-using-their-username-or-email-address (url updated)
It explains how to allow users to sign in using their username or email address.
how about filtering on the username or email if there is an @ and a . which would be characteristics for an email.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With