From eb169f73fafa4459ab254bb9856200995db5d361 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Mon, 29 Aug 2022 16:44:06 +0200 Subject: [PATCH] Improved update/save admin user --- dev/Settings/Admin/Security.js | 4 ++-- .../app/libraries/RainLoop/ActionsAdmin.php | 18 +++++++----------- .../Views/Admin/AdminSettingsSecurity.html | 12 ++++++------ 3 files changed, 15 insertions(+), 19 deletions(-) diff --git a/dev/Settings/Admin/Security.js b/dev/Settings/Admin/Security.js index 6567f8d13..1d7641713 100644 --- a/dev/Settings/Admin/Security.js +++ b/dev/Settings/Admin/Security.js @@ -71,11 +71,11 @@ export class AdminSettingsSecurity extends AbstractViewSettings { this.adminTOTP(SettingsGet('AdminTOTP')); decorateKoCommands(this, { - saveNewAdminPasswordCommand: self => self.adminLogin().trim() && self.adminPassword() + saveAdminUserCommand: self => self.adminLogin().trim() && self.adminPassword() }); } - saveNewAdminPasswordCommand() { + saveAdminUserCommand() { if (!this.adminLogin().trim()) { this.adminLoginError(true); return false; diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php b/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php index 0e5a2f927..28503d0c6 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/ActionsAdmin.php @@ -181,29 +181,25 @@ class ActionsAdmin extends Actions $bResult = false; $oConfig = $this->Config(); - $sLogin = \trim($this->GetActionParam('Login', '')); $sPassword = $this->GetActionParam('Password', ''); $this->Logger()->AddSecret($sPassword); $sNewPassword = $this->GetActionParam('NewPassword', ''); - if (\strlen(\trim($sNewPassword))) - { + if (\strlen($sNewPassword)) { $this->Logger()->AddSecret($sNewPassword); } $passfile = APP_PRIVATE_DATA.'admin_password.txt'; - $oConfig->Set('security', 'admin_totp', $this->GetActionParam('TOTP', '')); - - if ($oConfig->ValidatePassword($sPassword)) - { - if (\strlen($sLogin)) - { + if ($oConfig->ValidatePassword($sPassword)) { + $sLogin = \trim($this->GetActionParam('Login', '')); + if (\strlen($sLogin)) { $oConfig->Set('security', 'admin_login', $sLogin); } - if (\strlen(\trim($sNewPassword))) - { + $oConfig->Set('security', 'admin_totp', $this->GetActionParam('TOTP', '')); + + if (\strlen($sNewPassword)) { $oConfig->SetPassword($sNewPassword); if (\is_file($passfile) && \trim(\file_get_contents($passfile)) !== $sNewPassword) { \unlink($passfile); diff --git a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsSecurity.html b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsSecurity.html index 6bb9c6b7d..d2eddfe67 100644 --- a/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsSecurity.html +++ b/snappymail/v/0.0.0/app/templates/Views/Admin/AdminSettingsSecurity.html @@ -22,16 +22,16 @@
-
- - -
+
+ + +
-