diff --git a/modules/os2forms_nemid/os2forms_nemid.links.menu.yml b/modules/os2forms_nemid/os2forms_nemid.links.menu.yml
new file mode 100644
index 00000000..9b265214
--- /dev/null
+++ b/modules/os2forms_nemid/os2forms_nemid.links.menu.yml
@@ -0,0 +1,5 @@
+os2forms_nemid.settings:
+ title: OS2Forms NemID settings
+ description: Settings for OS2Forms NemID.
+ route_name: os2web_nemid.settings_form
+ parent: system.admin_config_system
diff --git a/modules/os2forms_nemid/os2forms_nemid.routing.yml b/modules/os2forms_nemid/os2forms_nemid.routing.yml
new file mode 100644
index 00000000..6d8af54a
--- /dev/null
+++ b/modules/os2forms_nemid/os2forms_nemid.routing.yml
@@ -0,0 +1,7 @@
+os2web_nemid.settings_form:
+ path: '/admin/config/system/os2forms_nemid'
+ defaults:
+ _title: 'OS2Forms Nemid settings'
+ _form: 'Drupal\os2forms_nemid\Form\SettingsForm'
+ requirements:
+ _permission: 'administer site configuration'
diff --git a/modules/os2forms_nemid/src/EventSubscriber/NemloginRedirectSubscriber.php b/modules/os2forms_nemid/src/EventSubscriber/NemloginRedirectSubscriber.php
index c6d7515e..4d45b0a2 100644
--- a/modules/os2forms_nemid/src/EventSubscriber/NemloginRedirectSubscriber.php
+++ b/modules/os2forms_nemid/src/EventSubscriber/NemloginRedirectSubscriber.php
@@ -5,6 +5,7 @@
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Url;
use Drupal\os2web_nemlogin\Service\AuthProviderService;
+use Drupal\os2forms_nemid\Form\SettingsForm;
use Drupal\webform\Entity\Webform;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\KernelEvents;
@@ -103,7 +104,6 @@ public function redirectToNemlogin(GetResponseEvent $event) {
if (isset($webformNemidSettings['nemlogin_auto_redirect'])) {
$nemlogin_auto_redirect = $webformNemidSettings['nemlogin_auto_redirect'];
}
-
// Checking if $nemlogin_auto_redirect is on.
if ($nemlogin_auto_redirect) {
// Killing cache so that positive or negative redirect decision is not
@@ -120,11 +120,14 @@ public function redirectToNemlogin(GetResponseEvent $event) {
$event->stopPropagation();
}
else {
- \Drupal::messenger()
- ->addMessage(t('This webform requires a valid NemID authentication and is not visible without it. You currently have an active NemID authentication session. If you do not want to proceed with this webform press log out to return back to the front page.', [
- '@logout' => $this->nemloginAuthProvider->getLogoutUrl(['query' => ['destination' => Url::fromRoute('')->toString()]])
- ->toString(),
- ]));
+ $settingFormConfig = \Drupal::config(SettingsForm::$configName);
+ if (!$settingFormConfig->get('os2forms_nemid_hide_active_nemid_session_message')) {
+ \Drupal::messenger()
+ ->addMessage(t('This webform requires a valid NemID authentication and is not visible without it. You currently have an active NemID authentication session. If you do not want to proceed with this webform press log out to return back to the front page.', [
+ '@logout' => $this->nemloginAuthProvider->getLogoutUrl(['query' => ['destination' => Url::fromRoute('')->toString()]])
+ ->toString(),
+ ]));
+ }
}
}
}
diff --git a/modules/os2forms_nemid/src/Form/SettingsForm.php b/modules/os2forms_nemid/src/Form/SettingsForm.php
new file mode 100644
index 00000000..527aeac6
--- /dev/null
+++ b/modules/os2forms_nemid/src/Form/SettingsForm.php
@@ -0,0 +1,65 @@
+ 'checkbox',
+ '#title' => t('Hide message about active Nemid session, if it exists.'),
+ '#description' => t('If checked, meessage aboout active NemID session will not shown on webform page'),
+ '#default_value' => $this->config(SettingsForm::$configName)
+ ->get('os2forms_nemid_hide_active_nemid_session_message'),
+ ];
+
+ return parent::buildForm($form, $form_state);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function submitForm(array &$form, FormStateInterface $form_state) {
+ $values = $form_state->getValues();
+
+ $config = $this->config(SettingsForm::$configName);
+ foreach ($values as $key => $value) {
+ $config->set($key, $value);
+ }
+ $config->save();
+
+ parent::submitForm($form, $form_state);
+ }
+
+}