-
I am using the Auth module. What is the best way to change a users password on the users request? I have a form with the old password and the new password. How do I verify that the old password is the correct password and how do I update the password in the database? |
Beta Was this translation helpful? Give feedback.
Answered by
ibnsultan
Sep 3, 2024
Replies: 1 comment
-
You can use the Leaf Password module to do that, which is aleady loaded as a Helper class assuming you're using a leaf mvc, a rough implementtion would be something like this use App\Models\User;
use Leaf\Helpers\Password;
$oldPassword = 'theOldPass';
$newPassword = 'theNewPass';
$user = User::find(:id);
if(Password::verify($oldPassword, $user->password){
$user->password = Password::hash($newPassword)
$user->save();
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
agedeo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the Leaf Password module to do that, which is aleady loaded as a Helper class
assuming you're using a leaf mvc, a rough implementtion would be something like this