Use existing data in the database for authentication

1

I have a database with already existing data, with name, CPF, RG and other personal data. I need to implement a login system, but I wanted the user to be in the case the registration number and the password the CPF, for example. In the login statements, I'm always prompted to do a new model with username and password. I would like to ask if I could use the same table that I already have the personal data to login to, or would I have to copy the data from this table to a new model, dedicated only to User?

What if I wanted to let the user log in with both email and registration number? How would you do this query?

    
asked by anonymous 20.12.2016 / 16:23

1 answer

0

In this case, it is easier for you to create a password field, in this same table, and throw the guy's CPF to this field (by default), it is up to you to encrypt this password or not. Enjoy and create the email field together

First make a validation on what the guy typed, with regex, this is what you are directed to for email validation or name. For validation in Ruby, follow the link: link

Since then the validation is normal. based on what you have for that record.

    
20.12.2016 / 19:40