-
app/Rules/PasscheckRule.php
Open in GitHubuse 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 GitHubuse 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()], ]; } }