Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

laravelio/laravel.io

2497 stars
2 code files
View laravelio/laravel.io on GitHub

app/Rules/PasscheckRule.php

Open in GitHub
use Illuminate\Contracts\Validation\Rule;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Hash;
 
final class PasscheckRule implements Rule
{
public function passes($attribute, $value): bool
{
return Hash::check($value, Auth::user()->getAuthPassword());
}
 
public function message(): string
{
return 'Your current password is incorrect.';
}
}

app/Http/Requests/UpdatePasswordRequest.php

Open in GitHub
use App\Rules\PasscheckRule;
use Illuminate\Validation\Rules\Password;
 
class UpdatePasswordRequest extends Request
{
public function rules()
{
return [
'current_password' => ['sometimes', 'required', new PasscheckRule()],
'password' => ['required', 'confirmed', Password::min(8)->uncompromised()],
];
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.