/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/auth/src/Authenticator
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakedc/auth/src/Authenticator/TwoFactorAuthenticator.php (3157B)
null,
'urlChecker' => 'Authentication.Default',
];
/**
* Prepares the error object for a login URL error
*
* @param \Psr\Http\Message\ServerRequestInterface $request The request that contains login information.
* @return \Authentication\Authenticator\ResultInterface
*/
protected function _buildLoginUrlErrorResult($request)
{
$errors = [
sprintf(
'Login URL `%s` did not match `%s`.',
(string)$request->getUri(),
implode('` or `', (array)$this->getConfig('loginUrl'))
),
];
return new Result(null, Result::FAILURE_OTHER, $errors);
}
/**
* Authenticates the identity contained in a request. Will use the `config.userModel`, and `config.fields`
* to find POST data that is used to find a matching record in the `config.userModel`. Will return false if
* there is no post data, either username or password is missing, or if the scope conditions have not been met.
*
* @param \Psr\Http\Message\ServerRequestInterface $request The request that contains login information.
* @return \Authentication\Authenticator\ResultInterface
*/
public function authenticate(ServerRequestInterface $request): ResultInterface
{
if (!$this->_checkUrl($request)) {
return $this->_buildLoginUrlErrorResult($request);
}
/**
* @var \Cake\Http\Session $session
*/
$session = $request->getAttribute('session');
/** @var array|\ArrayAccess $data */
$data = $session->read(self::USER_SESSION_KEY);
if (!empty($data)) {
$session->delete(self::USER_SESSION_KEY);
return new Result($data, Result::SUCCESS);
}
return new Result(null, Result::FAILURE_CREDENTIALS_MISSING, [
'Login credentials not found',
]);
}
}