mercredi 25 mars 2020

Hash::check always return false when compare password

I passed password that inserted from form (confirm_password) that i want to check through

$.ajax({
                url: "",
                method: "POST",
                //data: new FormData(this),
                data:"current_password="+current_password,
                dataType: 'JSON',
                contentType: false,
                cache: false,
                processData: false,
                success: function(response) {
                        if(response.success) {
                            showMessage("error", response.message);
                        } else {
                            showMessage("error", response.message);
                        }
                    }
            });

After, I checked this confirm_password and user password. But, I have false output when use Hash::check()

public function password_verification(Request $request){
    $verify_password = $request->current_password;
    $password = Auth::user()->password;
    if (Hash::check($verify_password,$password)) {
        $res['success'] = true;
        $res['message'] = "Success";
        return response($res);
    }else{
        $res['success'] = false;
        $res['message'] = "Error";
        return response($res);
    }
} 

When I input 111111 in current_password, I checked $encrypted_verify_password and $password. $encrypted_verify_password = $2y$10$w0c./s4rwd.aTE99bdCf.O4a7fvDFERZ2isww.9QYvDZHYmFRDohu (its value changed when recall this fuction) $password = $2y$10$mw3Wupj5nCYGJPnQIT53QuDzkxka//sncbpG8nfdF/2FOjQOsK3Au

What is solution?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire