How to implement login with attribute coming from another table with Devise in Rails 4?

1

I currently have a User Template that has a has_one relationship with Customer .

In the customer tables I have the CPF field that the user informs when to register.

I need to implement a login where the user inputs the e-mail or CPF to log in to the system.

    
asked by anonymous 08.09.2016 / 23:18

1 answer

0

The Devise documentation has an example of how to resolve this. It uses username or e-mail to exemplify, but easily adapts to CPF or e-mail . Take a look here is a somewhat laborious process, so I've put the link to you from a strong secure :).

So, to adapt to your case I think you'll have to change the behavior of find_for_database_authentication where you'll get CPF in the Customer table.

    
07.10.2016 / 20:18