mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-08-05 15:47:25 +02:00
Re-implement method 'canResetPassword' using 'canResetPasswordOrThrow'
This commit is contained in:
10
src/Auth.php
10
src/Auth.php
@@ -1250,18 +1250,10 @@ final class Auth extends UserManager {
|
|||||||
*/
|
*/
|
||||||
public function canResetPassword($selector, $token) {
|
public function canResetPassword($selector, $token) {
|
||||||
try {
|
try {
|
||||||
// pass an invalid password intentionally to force an expected error
|
$this->canResetPasswordOrThrow($selector, $token);
|
||||||
$this->resetPassword($selector, $token, null);
|
|
||||||
|
|
||||||
// we should already be in the `catch` block now so this is not expected
|
|
||||||
throw new AuthError();
|
|
||||||
}
|
|
||||||
// if the password is the only thing that's invalid
|
|
||||||
catch (InvalidPasswordException $e) {
|
|
||||||
// the password can be reset
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// if some other things failed (as well)
|
|
||||||
catch (AuthException $e) {
|
catch (AuthException $e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user