[ 'plugin' => 'CakeDC/Users', 'controller' => 'Users', 'action' => 'socialEmail', ], 'urlChecker' => 'Authentication.CakeRouter', ]; /** * 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); } $rawData = $request->getAttribute('session')->read(Configure::read('Users.Key.Session.social')); $body = $request->getParsedBody(); $email = $body['email'] ?? null; if (empty($rawData) || empty($email)) { return new Result(null, Result::FAILURE_CREDENTIALS_MISSING); } $rawData['email'] = $email; return $this->identify($rawData); } }