Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel check old password

use IlluminateSupportFacadesHash;
$user = User::findOrFail($id);

/*
* Validate all input fields
*/
$request->validate([
    'password' => 'required',
    'new_password' => 'confirmed|max:8|different:password',
]);

if (Hash::check($request->password, $user->password)) { 
   $user->fill([
    'password' => Hash::make($request->new_password)
    ])->save();

    return redirect()->route('your.route')->with('success', 'Password changed');

} else {
    return redirect()->route('your.route')->with('error', 'Password does not match');
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #check #password
ADD COMMENT
Topic
Name
7+1 =