Authenticate with encrypted user´s email in Laravel / Foritfy

47 views Asked by At

I use casting in Laravel to encrypt name and email of a user model in the database. That works great - if a new model is stored it´s encrypted and if a model is retrieved the value is decrypted automatically:

class User extends Authenticatable implements MustVerifyEmail {   
    protected $casts = [
        'email_verified_at' => 'datetime',
        'password' => 'hashed',
        'name' => 'encrypted',
        'email' => 'encrypted',
    ];
}

For handling the authentication process I´m using Fortify and here is my issue: As soon as I encrypt the email adress, Login isn´t working any more cause Fortify seems to compare the "plain" email address submitted by the user with the encrypted address in the database.

Is there a way to combine "native" laravel encryption casting with Fortify authentification? E.g. configure a callback to encrypt the email address before it´s compared?

0

There are 0 answers