false, 'reason' => lang('Auth.badAttempt'), ]); } $givenPassword = (string) $credentials['password']; unset($credentials['password']); $user = $this->provider->findByCredentials($credentials); if ($user === null) { return new Result([ 'success' => false, 'reason' => lang('Auth.badAttempt'), ]); } $hash = $user->password_hash ?? null; if (!is_string($hash) || trim($hash) === '') { return new Result([ 'success' => false, 'reason' => lang('Auth.invalidPassword'), ]); } /** @var Passwords $passwords */ $passwords = service('passwords'); if (!$passwords->verify($givenPassword, $hash)) { return new Result([ 'success' => false, 'reason' => lang('Auth.invalidPassword'), ]); } if ($passwords->needsRehash($hash)) { $user->password_hash = $passwords->hash($givenPassword); $this->provider->save($user); } return new Result([ 'success' => true, 'extraInfo' => $user, ]); } }