mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-08 00:02:15 +01:00
add support for passwordless user creation; add filament loading support for new laravel modules namespacing; add support for pluggable password reset and login rules
46 lines
1.3 KiB
PHP
46 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Actions\Fortify;
|
|
|
|
use App\Models\User;
|
|
use App\Providers\FortifyServiceProvider;
|
|
use Illuminate\Auth\Passwords\PasswordBroker;
|
|
use Illuminate\Support\Facades\Hash;
|
|
use Illuminate\Support\Facades\Password;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use Illuminate\Validation\ValidationException;
|
|
use Laravel\Fortify\Contracts\ResetsUserPasswords;
|
|
|
|
class ResetUserPassword implements ResetsUserPasswords
|
|
{
|
|
use PasswordValidationRules;
|
|
|
|
/**
|
|
* Validate and reset the user's forgotten password.
|
|
*
|
|
* @param array<string, string> $input
|
|
*/
|
|
public function reset(User $user, array $input): void
|
|
{
|
|
if (! FortifyServiceProvider::canResetPassword($user, $input)) {
|
|
/** @var PasswordBroker $broker */
|
|
$broker = Password::broker(config('fortify.passwords'));
|
|
$broker->deleteToken($user);
|
|
|
|
throw ValidationException::withMessages([
|
|
'email' => [__('This password reset link is invalid.')],
|
|
]);
|
|
}
|
|
|
|
Validator::make($input, [
|
|
'password' => $this->passwordRules(),
|
|
])->validate();
|
|
|
|
$user->forceFill([
|
|
'password' => Hash::make($input['password']),
|
|
])->save();
|
|
}
|
|
}
|