public function AuthenticationController::login in Janrain Registration 8
Login or reset a password for a user using Janrain API.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The incoming HTTP request.
Return value
string The URI to redirect the user to or the forgot password link usually used in email.
1 string reference to 'AuthenticationController::login'
File
- src/
Controller/ AuthenticationController.php, line 130
Class
- AuthenticationController
- Authentication controller.
Namespace
Drupal\janrain_capture\ControllerCode
public function login(Request $request) {
// Usually, this controller should return a URI to redirect a user to.
// This is valid for authentication. When the password reset requested
// a user will receive an email with the link and, opening it in a
// browser, this controller must show the real HTML page instead of
// just a URI.
$response_class = Response::class;
$one_time_login_link = FALSE;
if ($request->query
->get('url_type') === 'forgot') {
return $this
->forgot();
}
$destination_url = $this
->getDestinationUrl($request)
->setAbsolute()
->toString();
try {
// The authentication can throw exceptions so their messages
// will be exposed on the frontend.
$this->captureApi
->authenticate($this
->getAuthorizationCode($request), $request
->getUri());
if ($one_time_login_link) {
$this
->messenger()
->addStatus('You have been successfully logged in via one-time login link.');
}
$module_handler = \Drupal::moduleHandler();
$module_handler
->alter('janrain_capture_auth_destination', $destination_url, $this->captureApi
->getUserProfile(), $this->captureApi
->getCurrentUser());
} catch (\Throwable $e) {
$this
->messenger()
->addError($e
->getMessage());
}
return new $response_class($destination_url);
}