File gh-pr-82_hidepasswordlogin.patch of Package matomo-plugin-LoginOIDC

From 4ed18ad30f6d5ea0cc104e5f849682914837eb8d Mon Sep 17 00:00:00 2001
From: scott-amgen <106999752+scott-amgen@users.noreply.github.com>
Date: Tue, 22 Nov 2022 15:10:08 -0800
Subject: [PATCH 1/6] Create loginModHidePwLogin.css

---
 stylesheets/loginModHidePwLogin.css | 7 +++++++
 1 file changed, 7 insertions(+)
 create mode 100644 stylesheets/loginModHidePwLogin.css

diff --git a/stylesheets/loginModHidePwLogin.css b/stylesheets/loginModHidePwLogin.css
new file mode 100644
index 0000000..66138e1
--- /dev/null
+++ b/stylesheets/loginModHidePwLogin.css
@@ -0,0 +1,7 @@
+.loginForm #login_form {
+    display: none;
+}
+
+.loginForm #nav {
+    display: none;
+}

From 07c74ea5fa111e134c04db73c94ad5a5d0bdac8c Mon Sep 17 00:00:00 2001
From: scott-amgen <106999752+scott-amgen@users.noreply.github.com>
Date: Tue, 22 Nov 2022 15:24:43 -0800
Subject: [PATCH 2/6] Update SystemSettings.php

---
 SystemSettings.php | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/SystemSettings.php b/SystemSettings.php
index 08f2d2e..651f8df 100644
--- a/SystemSettings.php
+++ b/SystemSettings.php
@@ -41,6 +41,13 @@ class SystemSettings extends \Piwik\Settings\Plugin\SystemSettings
      */
     public $disableDirectLoginUrl;
 
+    /**
+     * Whether to hide standard password login form.
+     *
+     * @var bool
+     */
+    public $hidePasswordLogin;
+
     /**
      * Whether new Matomo accounts should be created for unknown users
      *
@@ -149,6 +156,7 @@ protected function init()
         $this->disableSuperuser = $this->createDisableSuperuserSetting();
         $this->disablePasswordConfirmation = $this->createDisablePasswordConfirmationSetting();
         $this->disableDirectLoginUrl = $this->createDisableDirectLoginUrlSetting();
+        $this->hidePasswordLogin = $this->createHidePasswordLoginSetting();
         $this->allowSignup = $this->createAllowSignupSetting();
         $this->bypassTwoFa = $this->createBypassTwoFaSetting();
         $this->autoLinking = $this->createAutoLinkingSetting();
@@ -206,6 +214,20 @@ private function createDisableDirectLoginUrlSetting() : SystemSetting
             $field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
         });
     }
+    
+    /**
+     * Add hide password login setting.
+     *
+     * @return SystemSetting
+     */
+    private function createHidePasswordLoginSetting() : SystemSetting
+    {
+        return $this->makeSetting("hidePasswordLogin", $default = false, FieldConfig::TYPE_BOOL, function(FieldConfig $field) {
+            $field->title = Piwik::translate("LoginOIDC_SettingHidePasswordLogin");
+            $field->description = Piwik::translate("LoginOIDC_SettingHidePasswordLoginHelp");
+            $field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
+        });
+    }
 
     /**
      * Add allowSignup setting.

From 0103c84b828aad06a1932caabfe6f6c0d0e6c449 Mon Sep 17 00:00:00 2001
From: scott-amgen <106999752+scott-amgen@users.noreply.github.com>
Date: Tue, 22 Nov 2022 15:26:37 -0800
Subject: [PATCH 3/6] Update en.json

---
 lang/en.json | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lang/en.json b/lang/en.json
index 411697c..39ca4d7 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -6,6 +6,7 @@
         "SettingDisablePasswordConfirmationHelp": "Certain administrational tasks require a password confirmation. When administrators are using this plugin and do not have a password they could confirm, this option can be used to skip the dialogue, when signed in via LoginOIDC",
         "SettingDisableDirectLoginUrl": "Disable direct login url",
         "SettingDisableDirectLoginUrlHelp": "When checked, users have to inititate the login via the Matomo login page. Otherwise the login button can be embedded in third-party services.",
+        "SettingHidePasswordLogin": "When checked, will hide standard username and password login prompt.",
         "SettingAllowSignup": "Create new users when users try to log in with unknown OIDC accounts",
         "SettingAllowSignupHelp": "",
         "SettingBypassTwoFa": "Disable second factor when sign in with OIDC",

From 72071895c2183dc939eb63b350a8f97247c8a5b8 Mon Sep 17 00:00:00 2001
From: scott-amgen <106999752+scott-amgen@users.noreply.github.com>
Date: Tue, 22 Nov 2022 15:28:43 -0800
Subject: [PATCH 4/6] Update fr.json

---
 lang/fr.json | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lang/fr.json b/lang/fr.json
index 7820f3b..608a2c4 100644
--- a/lang/fr.json
+++ b/lang/fr.json
@@ -4,6 +4,7 @@
         "SettingDisableSuperuserHelp": "",
         "SettingDisableDirectLoginUrl": "Désactiver l'url de connexion directe",
         "SettingDisableDirectLoginUrlHelp": "",
+        "SettingHidePasswordLogin": "Lorsque cette option est cochée, elle masque l'invite de connexion standard pour le nom d'utilisateur et le mot de passe.",
         "SettingAllowSignup": "Créer une nouveau compte utilisateur quand les utilisateurs tentent de se connecter avec un compte OIDC inconnu",
         "SettingAllowSignupHelp": "",
         "SettingBypassTwoFa": "Désactiver le 2è facteur lors d'une connexion avec OIDC",

From 20f3f24e9e9664c4b69c999986a32c378003640a Mon Sep 17 00:00:00 2001
From: scott-amgen <106999752+scott-amgen@users.noreply.github.com>
Date: Tue, 22 Nov 2022 15:29:46 -0800
Subject: [PATCH 5/6] Update de.json

---
 lang/de.json | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lang/de.json b/lang/de.json
index 3d1d44c..c09d30c 100644
--- a/lang/de.json
+++ b/lang/de.json
@@ -6,6 +6,7 @@
         "SettingDisablePasswordConfirmationHelp": "Einige administrative Aufgaben erfordern eine explizite Bestätigung des Benutzerpasswortes. Wenn Benutzer ohne gesetztes Passwort Matomo benutzen kann über diese Einstellung der Bestätigungsdialog überspringbar gemacht werden.",
         "SettingDisableDirectLoginUrl": "Deaktiviere direkten Login Link",
         "SettingDisableDirectLoginUrlHelp": "Wenn der Haken gesetzt ist muss der Login über die Login-Seite initiiert werden, anderenfalls lässt sich die Loginschaltfläche auch von dritten Seiten einbinden.",
+        "SettingHidePasswordLogin": "Wenn diese Option aktiviert ist, wird die Standard-Anmeldeaufforderung für Benutzername und Passwort ausgeblendet.",
         "SettingAllowSignup": "Erstelle automatisch einen neuen Account, wenn sich ein unbekannter neuer Benutzer einloggt",
         "SettingAllowSignupHelp": "",
         "SettingAuthenticationName": "Name",

From c461c99cf8cc6c9fe353b9da53ecc7fe7ed465cd Mon Sep 17 00:00:00 2001
From: scott-amgen <106999752+scott-amgen@users.noreply.github.com>
Date: Tue, 22 Nov 2022 15:32:04 -0800
Subject: [PATCH 6/6] Update LoginOIDC.php

---
 LoginOIDC.php | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/LoginOIDC.php b/LoginOIDC.php
index fa38066..82ee450 100644
--- a/LoginOIDC.php
+++ b/LoginOIDC.php
@@ -75,7 +75,12 @@ private function shouldHandleRememberMe() : bool
      */
     public function getStylesheetFiles(array &$files)
     {
+        $settings = new SystemSettings();
+        $hidePasswordLogin = $settings->hidePasswordLogin->getValue();
         $files[] = "plugins/LoginOIDC/stylesheets/loginMod.css";
+        if ($hidePasswordLogin) {
+            $files[] = "plugins/LoginOIDC/stylesheets/loginModHidePwLogin.css";
+        }
     }
 
     /**
openSUSE Build Service is sponsored by