F
Filament15mo ago
Arko

Validate current password

I'm creating a password update field, where I ask for the users current password and then for the new one with confirmation. Is there any built-in method to validate their current password against the database?
Solution:
Ended up just creating a custom rule for this: ```php TextInput::make('current_password') ->label(__('Current password')) ->password()...
Jump to solution
2 Replies
Solution
Arko
Arko15mo ago
Ended up just creating a custom rule for this:
TextInput::make('current_password')
->label(__('Current password'))
->password()
->rules([
function () {
return function (string $attribute, $value, Closure $fail) {
if (! Hash::check($value, auth()->user()->password)) {
$fail('Current password is incorrect.');
}
};
},
]),
TextInput::make('current_password')
->label(__('Current password'))
->password()
->rules([
function () {
return function (string $attribute, $value, Closure $fail) {
if (! Hash::check($value, auth()->user()->password)) {
$fail('Current password is incorrect.');
}
};
},
]),
Somebody
Somebody15mo ago
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.

Did you find this page helpful?