public function AuthorizeForm::submitForm in OAuth2 Server 8
Same name and namespace in other branches
- 2.0.x src/Form/AuthorizeForm.php \Drupal\oauth2_server\Form\AuthorizeForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ AuthorizeForm.php, line 94
Class
- AuthorizeForm
- Class Authorize Form.
Namespace
Drupal\oauth2_server\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// A login happened. Create the request with parameters from the session.
if (!empty($_SESSION['oauth2_server_authorize'])) {
$bridgeRequest = $_SESSION['oauth2_server_authorize'];
unset($_SESSION['oauth2_server_authorize']);
}
else {
$bridgeRequest = BridgeRequest::createFromRequest($this
->getRequest());
}
$authorized = $form_state
->getTriggeringElement()['#authorized'];
$server = $form_state
->getValue('client')
->getServer();
// Finish the authorization request.
$response = new BridgeResponse();
$oauth2_server = Utility::startServer($server, $this->storage);
$oauth2_server
->handleAuthorizeRequest($bridgeRequest, $response, $authorized, $this
->currentUser()
->id());
$form_state
->setResponse($response);
}