jeudi 28 janvier 2021

Two columns for password in Laravel for login

I have two password column one is password and other in temp_password, user can login with either password or temp_password for that i'm using following code:

if(Auth::attempt(['email' => request('email'), 'password' => request('password')])){ 
    echo "User Logged In";
} else if(Auth::attempt(['email' => request('email'), 'temp_password' => \Crypt::encrypt(request('password'))])) {
    echo "User Logged in";
} else {
    echo "Incorrect Credentials";
}

i'm getting this error :

Undefined index: password", exception: "ErrorException"

if i remove else if part it is working properly.

Any help is highly appreciated.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire