-
Notifications
You must be signed in to change notification settings - Fork 302
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9215e54
commit a9e68f2
Showing
2 changed files
with
47 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace Laravel\Fortify\Actions; | ||
|
||
use Illuminate\Contracts\Auth\StatefulGuard; | ||
use Laravel\Fortify\Fortify; | ||
|
||
class ConfirmPassword | ||
{ | ||
/** | ||
* Confirm that the given password is valid for the given user. | ||
* | ||
* @param \Illuminate\Contracts\Auth\StatefulGuard $guard | ||
* @param mixed $user | ||
* @param string $password | ||
* @return bool | ||
*/ | ||
public function __invoke(StatefulGuard $guard, $user, string $password) | ||
{ | ||
$username = config('fortify.username'); | ||
|
||
return is_null(Fortify::$confirmPasswordsUsingCallback) ? $guard->validate([ | ||
$username => $user->{$username}, | ||
'password' => $password, | ||
]) : $this->confirmPasswordUsingCustomCallback($user, $password); | ||
} | ||
|
||
/** | ||
* Confirm the user's password using a custom callback. | ||
* | ||
* @param mixed $user | ||
* @param string $password | ||
* @return bool | ||
*/ | ||
protected function confirmPasswordUsingCustomCallback($user, string $password) | ||
{ | ||
return call_user_func( | ||
Fortify::$confirmPasswordsUsingCallback, | ||
$user, | ||
$password | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters