1
I have a database with 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 case the registration number and password CPF, for example. In the demonstrations of how to login, I am always told to make a new model with user and password. Then I ask, could use the same table from which I already have personal data to log in, or would have to copy the data from this table to a new model, dedicated only to the User?
What if I wanted to let the user log in with both email and registration number? How would I do this query?
You can do it, but the structure’s gonna get weird. I suggest you create a data migration routine, where it feeds the new login table with the existing data. If you choose to keep the data like this, how will you make the user change the password ? The User’s email is already present in the existing table?
– Victor Tadashi
Hello, Victor. Not yet, emails would only be available after users update their registration. What I still can’t understand is how to use the data in the presenta table to authenticate. Just copy the dafos of the columns I want to use to authenticate to the table created by the new model?
– Kiek
Doubt: In your application each registered person will be a user ?
– Victor Tadashi
Yes, each registered person is a user. They can log into the system to change their registration data.
– Kiek
Okay, in this case, it’s easier for you to create a password field, on that same table, and play the guy’s number to that field (by default), it’s up to you to encrypt that password or not. Take advantage and create together the email field. What do you think? Starting from this definition, what’s the next problem ?
– Victor Tadashi
That’s exactly what I was thinking about doing. Besides, if I copied the data to another model, to each registered associate, I would have to migrate the data. Anyway, I only have doubts about how to allow the username to be both the registration and the email.
– Kiek