samedi 3 août 2019

Laravel 5.8 - save user emails encrypted

I'm looking for a way to encrypt the user emails in the database. Since Encrypt always generates a different string, it fails. So I took sha1.

in AuthenticatesUsers I've changed the credentials method to:

 protected function credentials(Request $request)
 {
    return ['email' => sha1(strtolower($request->email)), 'password' => ($request->password)];
 }

This works great for the login/registration. But there are problems with resetting the password.

Resetting the password uses the SendsPasswordResetEmails trait.

There it this credentials method:

protected function credentials(Request $request)
{
    return $request->only('email');
}

This always fails, cause it does not find the user (cause the user is saved with sha1 email)

if I change it to return ['email' => sha1(strtolower($request['email']))];

I get the error, that the email is not in the right RFC standart, to send a email. The Problem is, I don't really find the place, where laravel is searchig for the user with this email. Anyway, I don't really have a clue, how I can solve this problem at all.

I want to encrypt the email itself, because in germany there is a law which forces us to store personal data encrypted, like the email.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire