mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-06-28 14:55:48 +00:00
Improved update/save admin user
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -22,16 +22,16 @@
|
||||
</div>
|
||||
<div class="form-horizontal">
|
||||
<div class="legend" data-i18n="TAB_SECURITY/LEGEND_ADMIN_PANEL_ACCESS_CREDENTIALS"></div>
|
||||
<div class="control-group">
|
||||
<label data-i18n="TAB_SECURITY/LABEL_CURRENT_PASSWORD"></label>
|
||||
<input type="password" autocomplete="current-password" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="textInput: adminPassword">
|
||||
</div>
|
||||
<div class="control-group" data-bind="css: {'error': adminLoginError}">
|
||||
<label data-i18n="GLOBAL/USERNAME"></label>
|
||||
<input type="text" autocomplete="username" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="textInput: adminLogin">
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label data-i18n="TAB_SECURITY/LABEL_CURRENT_PASSWORD"></label>
|
||||
<input type="password" autocomplete="current-password" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
data-bind="textInput: adminPassword">
|
||||
</div>
|
||||
<div class="control-group" data-bind="css: {'error': adminPasswordNewError}">
|
||||
<label data-i18n="TAB_SECURITY/LABEL_NEW_PASSWORD"></label>
|
||||
<input type="password" autocomplete="new-password" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||
@@ -53,7 +53,7 @@
|
||||
<pre data-bind="text: viewQRCode" style="font-family:var(--fontMono);font-size:11px;letter-spacing:-1px;line-height:1;"></pre>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<a class="btn" data-bind="command: saveNewAdminPasswordCommand, css: { 'btn-success': saveSuccess, 'btn-danger': saveError }"
|
||||
<a class="btn" data-bind="command: saveAdminUserCommand, css: { 'btn-success': saveSuccess, 'btn-danger': saveError }"
|
||||
data-icon="🔑" data-i18n="GLOBAL/SAVE"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user