mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Improved update/save admin user
This commit is contained in:
parent
a3a20f8820
commit
eb169f73fa
3 changed files with 15 additions and 19 deletions
|
|
@ -71,11 +71,11 @@ export class AdminSettingsSecurity extends AbstractViewSettings {
|
||||||
this.adminTOTP(SettingsGet('AdminTOTP'));
|
this.adminTOTP(SettingsGet('AdminTOTP'));
|
||||||
|
|
||||||
decorateKoCommands(this, {
|
decorateKoCommands(this, {
|
||||||
saveNewAdminPasswordCommand: self => self.adminLogin().trim() && self.adminPassword()
|
saveAdminUserCommand: self => self.adminLogin().trim() && self.adminPassword()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
saveNewAdminPasswordCommand() {
|
saveAdminUserCommand() {
|
||||||
if (!this.adminLogin().trim()) {
|
if (!this.adminLogin().trim()) {
|
||||||
this.adminLoginError(true);
|
this.adminLoginError(true);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -181,29 +181,25 @@ class ActionsAdmin extends Actions
|
||||||
$bResult = false;
|
$bResult = false;
|
||||||
$oConfig = $this->Config();
|
$oConfig = $this->Config();
|
||||||
|
|
||||||
$sLogin = \trim($this->GetActionParam('Login', ''));
|
|
||||||
$sPassword = $this->GetActionParam('Password', '');
|
$sPassword = $this->GetActionParam('Password', '');
|
||||||
$this->Logger()->AddSecret($sPassword);
|
$this->Logger()->AddSecret($sPassword);
|
||||||
|
|
||||||
$sNewPassword = $this->GetActionParam('NewPassword', '');
|
$sNewPassword = $this->GetActionParam('NewPassword', '');
|
||||||
if (\strlen(\trim($sNewPassword)))
|
if (\strlen($sNewPassword)) {
|
||||||
{
|
|
||||||
$this->Logger()->AddSecret($sNewPassword);
|
$this->Logger()->AddSecret($sNewPassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
$passfile = APP_PRIVATE_DATA.'admin_password.txt';
|
$passfile = APP_PRIVATE_DATA.'admin_password.txt';
|
||||||
|
|
||||||
$oConfig->Set('security', 'admin_totp', $this->GetActionParam('TOTP', ''));
|
if ($oConfig->ValidatePassword($sPassword)) {
|
||||||
|
$sLogin = \trim($this->GetActionParam('Login', ''));
|
||||||
if ($oConfig->ValidatePassword($sPassword))
|
if (\strlen($sLogin)) {
|
||||||
{
|
|
||||||
if (\strlen($sLogin))
|
|
||||||
{
|
|
||||||
$oConfig->Set('security', 'admin_login', $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);
|
$oConfig->SetPassword($sNewPassword);
|
||||||
if (\is_file($passfile) && \trim(\file_get_contents($passfile)) !== $sNewPassword) {
|
if (\is_file($passfile) && \trim(\file_get_contents($passfile)) !== $sNewPassword) {
|
||||||
\unlink($passfile);
|
\unlink($passfile);
|
||||||
|
|
|
||||||
|
|
@ -22,16 +22,16 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="form-horizontal">
|
<div class="form-horizontal">
|
||||||
<div class="legend" data-i18n="TAB_SECURITY/LEGEND_ADMIN_PANEL_ACCESS_CREDENTIALS"></div>
|
<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}">
|
<div class="control-group" data-bind="css: {'error': adminLoginError}">
|
||||||
<label data-i18n="GLOBAL/USERNAME"></label>
|
<label data-i18n="GLOBAL/USERNAME"></label>
|
||||||
<input type="text" autocomplete="username" autocorrect="off" autocapitalize="off" spellcheck="false"
|
<input type="text" autocomplete="username" autocorrect="off" autocapitalize="off" spellcheck="false"
|
||||||
data-bind="textInput: adminLogin">
|
data-bind="textInput: adminLogin">
|
||||||
</div>
|
</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}">
|
<div class="control-group" data-bind="css: {'error': adminPasswordNewError}">
|
||||||
<label data-i18n="TAB_SECURITY/LABEL_NEW_PASSWORD"></label>
|
<label data-i18n="TAB_SECURITY/LABEL_NEW_PASSWORD"></label>
|
||||||
<input type="password" autocomplete="new-password" autocorrect="off" autocapitalize="off" spellcheck="false"
|
<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>
|
<pre data-bind="text: viewQRCode" style="font-family:var(--fontMono);font-size:11px;letter-spacing:-1px;line-height:1;"></pre>
|
||||||
</div>
|
</div>
|
||||||
<div class="control-group">
|
<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>
|
data-icon="🔑" data-i18n="GLOBAL/SAVE"></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue