Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions gigya_raas/src/GigyaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ public function gigyaRaasProcessFieldMapping(Request $request): AjaxResponse {
* @param \Symfony\Component\HttpFoundation\Request $request
* The incoming request object.
*
* @return bool|AjaxResponse The Ajax response
* @return \Drupal\Core\Ajax\AjaxResponse
* The Ajax response
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
Expand Down Expand Up @@ -438,7 +439,8 @@ public function gigyaRaasLoginAjax(Request $request) {

return $response;
}
return FALSE;

return $this->signedInAlertResponse();
}

/**
Expand Down Expand Up @@ -731,4 +733,24 @@ protected function editPhoneNumber($phoneNumber) {
return $phoneNumber;
}

/**
* Ajax alert shown when an already-authenticated user attempts to log in.
*
* This method logs and returns an Ajax response containing an alert
* message to inform the user that they are already signed in.
*
* @return \Drupal\Core\Ajax\AjaxResponse
* The Ajax response with an alert command.
*/
protected function signedInAlertResponse(): AjaxResponse {
// Log the event for debugging.
\Drupal::logger('gigya_raas')->notice('User attempted to log in while already authenticated.');

// Return the AjaxResponse with alert.
$response = new AjaxResponse();
$response->addCommand(new AlertCommand($this->t("You're already signed in.")));

return $response;
}

}