UI: Rename mail server value isDemo to showChangePassword. Fixed send test mail: not work for empty password fields
This commit is contained in:
parent
c01c075984
commit
a6fffcb8c3
@ -126,6 +126,10 @@ public class AdminController extends BaseController {
|
|||||||
accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.READ);
|
accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.READ);
|
||||||
adminSettings = checkNotNull(adminSettings);
|
adminSettings = checkNotNull(adminSettings);
|
||||||
if (adminSettings.getKey().equals("mail")) {
|
if (adminSettings.getKey().equals("mail")) {
|
||||||
|
if(!adminSettings.getJsonValue().has("password")) {
|
||||||
|
AdminSettings mailSettings = checkNotNull(adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, "mail"));
|
||||||
|
((ObjectNode) adminSettings.getJsonValue()).put("password", mailSettings.getJsonValue().get("password").asText());
|
||||||
|
}
|
||||||
String email = getCurrentUser().getEmail();
|
String email = getCurrentUser().getEmail();
|
||||||
mailService.sendTestMail(adminSettings.getJsonValue(), email);
|
mailService.sendTestMail(adminSettings.getJsonValue(), email);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -215,7 +215,7 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
|
|||||||
node.put("password", "");
|
node.put("password", "");
|
||||||
node.put("tlsVersion", "TLSv1.2");//NOSONAR, key used to identify password field (not password value itself)
|
node.put("tlsVersion", "TLSv1.2");//NOSONAR, key used to identify password field (not password value itself)
|
||||||
node.put("enableProxy", false);
|
node.put("enableProxy", false);
|
||||||
node.put("isDemo", true);
|
node.put("showChangePassword", false);
|
||||||
mailSettings.setJsonValue(node);
|
mailSettings.setJsonValue(node);
|
||||||
adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, mailSettings);
|
adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, mailSettings);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -126,10 +126,10 @@
|
|||||||
<input matInput formControlName="username" placeholder="{{ 'common.enter-username' | translate }}"
|
<input matInput formControlName="username" placeholder="{{ 'common.enter-username' | translate }}"
|
||||||
autocomplete="new-username"/>
|
autocomplete="new-username"/>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-checkbox *ngIf="!isDemo" formControlName="changePassword" style="padding-bottom: 16px;">
|
<mat-checkbox *ngIf="showChangePassword" formControlName="changePassword" style="padding-bottom: 16px;">
|
||||||
{{ 'admin.change-password' | translate }}
|
{{ 'admin.change-password' | translate }}
|
||||||
</mat-checkbox>
|
</mat-checkbox>
|
||||||
<mat-form-field class="mat-block" *ngIf="mailSettings.get('changePassword').value || isDemo">
|
<mat-form-field class="mat-block" *ngIf="mailSettings.get('changePassword').value || !showChangePassword">
|
||||||
<mat-label translate>common.password</mat-label>
|
<mat-label translate>common.password</mat-label>
|
||||||
<input matInput formControlName="password" type="password"
|
<input matInput formControlName="password" type="password"
|
||||||
placeholder="{{ 'common.enter-password' | translate }}" autocomplete="new-password">
|
placeholder="{{ 'common.enter-password' | translate }}" autocomplete="new-password">
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import { AdminService } from '@core/http/admin.service';
|
|||||||
import { ActionNotificationShow } from '@core/notification/notification.actions';
|
import { ActionNotificationShow } from '@core/notification/notification.actions';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { HasConfirmForm } from '@core/guards/confirm-on-exit.guard';
|
import { HasConfirmForm } from '@core/guards/confirm-on-exit.guard';
|
||||||
import { deepClone, isString } from '@core/utils';
|
import { isDefinedAndNotNull, isString } from '@core/utils';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { takeUntil } from 'rxjs/operators';
|
import { takeUntil } from 'rxjs/operators';
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ export class MailServerComponent extends PageComponent implements OnInit, OnDest
|
|||||||
mailSettings: FormGroup;
|
mailSettings: FormGroup;
|
||||||
adminSettings: AdminSettings<MailServerSettings>;
|
adminSettings: AdminSettings<MailServerSettings>;
|
||||||
smtpProtocols = ['smtp', 'smtps'];
|
smtpProtocols = ['smtp', 'smtps'];
|
||||||
isDemo = true;
|
showChangePassword = false;
|
||||||
|
|
||||||
tlsVersions = ['TLSv1', 'TLSv1.1', 'TLSv1.2', 'TLSv1.3'];
|
tlsVersions = ['TLSv1', 'TLSv1.1', 'TLSv1.2', 'TLSv1.3'];
|
||||||
|
|
||||||
@ -61,10 +61,11 @@ export class MailServerComponent extends PageComponent implements OnInit, OnDest
|
|||||||
if (this.adminSettings.jsonValue && isString(this.adminSettings.jsonValue.enableTls)) {
|
if (this.adminSettings.jsonValue && isString(this.adminSettings.jsonValue.enableTls)) {
|
||||||
this.adminSettings.jsonValue.enableTls = (this.adminSettings.jsonValue.enableTls as any) === 'true';
|
this.adminSettings.jsonValue.enableTls = (this.adminSettings.jsonValue.enableTls as any) === 'true';
|
||||||
}
|
}
|
||||||
this.isDemo = this.adminSettings.jsonValue.isDemo;
|
this.showChangePassword =
|
||||||
delete this.adminSettings.jsonValue.isDemo;
|
isDefinedAndNotNull(this.adminSettings.jsonValue.showChangePassword) ? this.adminSettings.jsonValue.showChangePassword : true ;
|
||||||
|
delete this.adminSettings.jsonValue.showChangePassword;
|
||||||
this.mailSettings.reset(this.adminSettings.jsonValue);
|
this.mailSettings.reset(this.adminSettings.jsonValue);
|
||||||
this.enableMailPassword(this.isDemo);
|
this.enableMailPassword(!this.showChangePassword);
|
||||||
this.enableProxyChanged();
|
this.enableProxyChanged();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -147,11 +148,9 @@ export class MailServerComponent extends PageComponent implements OnInit, OnDest
|
|||||||
this.adminSettings.jsonValue = {...this.adminSettings.jsonValue, ...this.mailSettingsFormValue};
|
this.adminSettings.jsonValue = {...this.adminSettings.jsonValue, ...this.mailSettingsFormValue};
|
||||||
this.adminService.saveAdminSettings(this.adminSettings).subscribe(
|
this.adminService.saveAdminSettings(this.adminSettings).subscribe(
|
||||||
(adminSettings) => {
|
(adminSettings) => {
|
||||||
adminSettings.jsonValue.password = this.mailSettings.value.password;
|
|
||||||
this.adminSettings = adminSettings;
|
this.adminSettings = adminSettings;
|
||||||
const formSettings = deepClone(this.adminSettings.jsonValue);
|
this.showChangePassword = true;
|
||||||
formSettings.changePassword = this.mailSettings.get('changePassword').value || this.isDemo;
|
this.mailSettings.reset(this.adminSettings.jsonValue);
|
||||||
this.mailSettings.reset(formSettings, {emitEvent: false});
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,7 +27,7 @@ export interface AdminSettings<T> {
|
|||||||
export declare type SmtpProtocol = 'smtp' | 'smtps';
|
export declare type SmtpProtocol = 'smtp' | 'smtps';
|
||||||
|
|
||||||
export interface MailServerSettings {
|
export interface MailServerSettings {
|
||||||
isDemo: boolean;
|
showChangePassword: boolean;
|
||||||
mailFrom: string;
|
mailFrom: string;
|
||||||
smtpProtocol: SmtpProtocol;
|
smtpProtocol: SmtpProtocol;
|
||||||
smtpHost: string;
|
smtpHost: string;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user