diff --git a/application/src/main/java/org/thingsboard/server/controller/AdminController.java b/application/src/main/java/org/thingsboard/server/controller/AdminController.java
index 33f2558fe3..d8406088c7 100644
--- a/application/src/main/java/org/thingsboard/server/controller/AdminController.java
+++ b/application/src/main/java/org/thingsboard/server/controller/AdminController.java
@@ -126,6 +126,10 @@ public class AdminController extends BaseController {
accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.READ);
adminSettings = checkNotNull(adminSettings);
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();
mailService.sendTestMail(adminSettings.getJsonValue(), email);
}
diff --git a/application/src/main/java/org/thingsboard/server/service/install/DefaultSystemDataLoaderService.java b/application/src/main/java/org/thingsboard/server/service/install/DefaultSystemDataLoaderService.java
index 019b899aec..7042bb6de1 100644
--- a/application/src/main/java/org/thingsboard/server/service/install/DefaultSystemDataLoaderService.java
+++ b/application/src/main/java/org/thingsboard/server/service/install/DefaultSystemDataLoaderService.java
@@ -215,7 +215,7 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService {
node.put("password", "");
node.put("tlsVersion", "TLSv1.2");//NOSONAR, key used to identify password field (not password value itself)
node.put("enableProxy", false);
- node.put("isDemo", true);
+ node.put("showChangePassword", false);
mailSettings.setJsonValue(node);
adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, mailSettings);
}
diff --git a/ui-ngx/src/app/modules/home/pages/admin/mail-server.component.html b/ui-ngx/src/app/modules/home/pages/admin/mail-server.component.html
index 954cddca45..384f402a65 100644
--- a/ui-ngx/src/app/modules/home/pages/admin/mail-server.component.html
+++ b/ui-ngx/src/app/modules/home/pages/admin/mail-server.component.html
@@ -126,10 +126,10 @@
-
+
{{ 'admin.change-password' | translate }}
-
+
common.password
diff --git a/ui-ngx/src/app/modules/home/pages/admin/mail-server.component.ts b/ui-ngx/src/app/modules/home/pages/admin/mail-server.component.ts
index fd4f5a871e..9750319565 100644
--- a/ui-ngx/src/app/modules/home/pages/admin/mail-server.component.ts
+++ b/ui-ngx/src/app/modules/home/pages/admin/mail-server.component.ts
@@ -25,7 +25,7 @@ import { AdminService } from '@core/http/admin.service';
import { ActionNotificationShow } from '@core/notification/notification.actions';
import { TranslateService } from '@ngx-translate/core';
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 { takeUntil } from 'rxjs/operators';
@@ -39,7 +39,7 @@ export class MailServerComponent extends PageComponent implements OnInit, OnDest
mailSettings: FormGroup;
adminSettings: AdminSettings;
smtpProtocols = ['smtp', 'smtps'];
- isDemo = true;
+ showChangePassword = false;
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)) {
this.adminSettings.jsonValue.enableTls = (this.adminSettings.jsonValue.enableTls as any) === 'true';
}
- this.isDemo = this.adminSettings.jsonValue.isDemo;
- delete this.adminSettings.jsonValue.isDemo;
+ this.showChangePassword =
+ isDefinedAndNotNull(this.adminSettings.jsonValue.showChangePassword) ? this.adminSettings.jsonValue.showChangePassword : true ;
+ delete this.adminSettings.jsonValue.showChangePassword;
this.mailSettings.reset(this.adminSettings.jsonValue);
- this.enableMailPassword(this.isDemo);
+ this.enableMailPassword(!this.showChangePassword);
this.enableProxyChanged();
}
);
@@ -147,11 +148,9 @@ export class MailServerComponent extends PageComponent implements OnInit, OnDest
this.adminSettings.jsonValue = {...this.adminSettings.jsonValue, ...this.mailSettingsFormValue};
this.adminService.saveAdminSettings(this.adminSettings).subscribe(
(adminSettings) => {
- adminSettings.jsonValue.password = this.mailSettings.value.password;
this.adminSettings = adminSettings;
- const formSettings = deepClone(this.adminSettings.jsonValue);
- formSettings.changePassword = this.mailSettings.get('changePassword').value || this.isDemo;
- this.mailSettings.reset(formSettings, {emitEvent: false});
+ this.showChangePassword = true;
+ this.mailSettings.reset(this.adminSettings.jsonValue);
}
);
}
diff --git a/ui-ngx/src/app/shared/models/settings.models.ts b/ui-ngx/src/app/shared/models/settings.models.ts
index 8bd4d8e215..8b2d4aac78 100644
--- a/ui-ngx/src/app/shared/models/settings.models.ts
+++ b/ui-ngx/src/app/shared/models/settings.models.ts
@@ -27,7 +27,7 @@ export interface AdminSettings {
export declare type SmtpProtocol = 'smtp' | 'smtps';
export interface MailServerSettings {
- isDemo: boolean;
+ showChangePassword: boolean;
mailFrom: string;
smtpProtocol: SmtpProtocol;
smtpHost: string;