Commit e002d7e4 authored by Mario Steinitz's avatar Mario Steinitz
Browse files

Revert "Issue #2961752: Replace 'drupal_set_message()' with messenger service...

Revert "Issue #2961752: Replace 'drupal_set_message()' with messenger service in redirect controller and accounts form."
This reverts commit 11d078fc.
parent dee9dfe9
......@@ -5,7 +5,6 @@ namespace Drupal\openid_connect\Controller;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
......@@ -38,13 +37,6 @@ class OpenIDConnectRedirectController extends ControllerBase implements AccessIn
*/
protected $requestStack;
/**
* The Messenger service.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/**
* The logger factory.
*
......@@ -73,7 +65,6 @@ class OpenIDConnectRedirectController extends ControllerBase implements AccessIn
OpenIDConnectClientManager $plugin_manager,
OpenIDConnect $openid_connect,
RequestStack $request_stack,
MessengerInterface $messenger,
LoggerChannelFactoryInterface $logger_factory,
AccountInterface $current_user
) {
......@@ -82,7 +73,6 @@ class OpenIDConnectRedirectController extends ControllerBase implements AccessIn
$this->requestStack = $request_stack;
$this->loggerFactory = $logger_factory;
$this->currentUser = $current_user;
$this->messenger = $messenger;
}
/**
......@@ -93,7 +83,6 @@ class OpenIDConnectRedirectController extends ControllerBase implements AccessIn
$container->get('plugin.manager.openid_connect_client.processor'),
$container->get('openid_connect.openid_connect'),
$container->get('request_stack'),
$container->get('messenger'),
$container->get('logger.factory'),
$container->get('current_user')
);
......@@ -170,7 +159,7 @@ class OpenIDConnectRedirectController extends ControllerBase implements AccessIn
])) {
// If we have an one of the above errors, that means the user hasn't
// granted the authorization for the claims.
$this->messenger->addWarning($this->t('Logging in with @provider has been canceled.', $provider_param));
drupal_set_message($this->t('Logging in with @provider has been canceled.', $provider_param), 'warning');
}
else {
// Any other error should be logged. E.g. invalid scope.
......@@ -180,7 +169,7 @@ class OpenIDConnectRedirectController extends ControllerBase implements AccessIn
];
$message = 'Authorization failed: @error. Details: @details';
$this->loggerFactory->get('openid_connect_' . $client_name)->error($message, $variables);
$this->messenger->addError($this->t('Could not authenticate with @provider.', $provider_param));
drupal_set_message($this->t('Could not authenticate with @provider.', $provider_param), 'error');
}
}
else {
......@@ -208,7 +197,7 @@ class OpenIDConnectRedirectController extends ControllerBase implements AccessIn
break;
default:
$this->messenger->addError($this->t('Logging in with @provider could not be completed due to an error.', $provider_param));
drupal_set_message($this->t('Logging in with @provider could not be completed due to an error.', $provider_param), 'error');
break;
}
}
......@@ -216,10 +205,10 @@ class OpenIDConnectRedirectController extends ControllerBase implements AccessIn
elseif ($parameters['op'] === 'connect' && $parameters['connect_uid'] === $this->currentUser->id()) {
$success = $this->openIDConnect->connectCurrentUser($client, $tokens);
if ($success) {
$this->messenger->addMessage($this->t('Account successfully connected with @provider.', $provider_param));
drupal_set_message($this->t('Account successfully connected with @provider.', $provider_param));
}
else {
$this->messenger->addError($this->t('Connecting with @provider could not be completed due to an error.', $provider_param));
drupal_set_message($this->t('Connecting with @provider could not be completed due to an error.', $provider_param), 'error');
}
}
}
......
......@@ -7,7 +7,6 @@ use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Session\AccountProxy;
use Drupal\openid_connect\OpenIDConnectSession;
......@@ -65,13 +64,6 @@ class OpenIDConnectAccountsForm extends FormBase implements ContainerInjectionIn
*/
protected $configFactory;
/**
* The Messenger service.
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
/**
* The constructor.
*
......@@ -87,17 +79,14 @@ class OpenIDConnectAccountsForm extends FormBase implements ContainerInjectionIn
* The OpenID Connect client manager.
* @param \Drupal\Core\Config\ConfigFactory $config_factory
* The config factory.
* @param \Drupal\Core\Messenger\MessengerInterface $messenger
* The messenger service.
*/
public function __construct(
AccountProxy $current_user,
OpenIDConnectSession $session,
OpenIDConnectAuthmap $authmap,
OpenIDConnectClaims $claims,
OpenIDConnectClientManager $plugin_manager,
ConfigFactory $config_factory,
MessengerInterface $messenger
AccountProxy $current_user,
OpenIDConnectSession $session,
OpenIDConnectAuthmap $authmap,
OpenIDConnectClaims $claims,
OpenIDConnectClientManager $plugin_manager,
ConfigFactory $config_factory
) {
$this->currentUser = $current_user;
......@@ -106,7 +95,6 @@ class OpenIDConnectAccountsForm extends FormBase implements ContainerInjectionIn
$this->claims = $claims;
$this->pluginManager = $plugin_manager;
$this->configFactory = $config_factory;
$this->messenger = $messenger;
}
/**
......@@ -205,12 +193,12 @@ class OpenIDConnectAccountsForm extends FormBase implements ContainerInjectionIn
if ($op === 'disconnect') {
$this->authmap->deleteAssociation($form_state->get('account')->id(), $client_name);
$client = $this->pluginManager->getDefinition($client_name);
$this->messenger->addMessage($this->t('Account successfully disconnected from @client.', ['@client' => $client['label']]));
drupal_set_message($this->t('Account successfully disconnected from @client.', ['@client' => $client['label']]));
return;
}
if ($this->currentUser->id() !== $form_state->get('account')->id()) {
$this->messenger->addError($this->t("You cannot connect another user's account."));
drupal_set_message($this->t("You cannot connect another user's account."), 'error');
return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment