Commit a6fffcb8c3ae134a6ad5ca833e5037bf082d68ff
1 parent
c01c0759
UI: Rename mail server value isDemo to showChangePassword. Fixed send test mail:…
… not work for empty password fields
Showing
5 changed files
with
16 additions
and
13 deletions
... | ... | @@ -126,6 +126,10 @@ public class AdminController extends BaseController { |
126 | 126 | accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.READ); |
127 | 127 | adminSettings = checkNotNull(adminSettings); |
128 | 128 | if (adminSettings.getKey().equals("mail")) { |
129 | + if(!adminSettings.getJsonValue().has("password")) { | |
130 | + AdminSettings mailSettings = checkNotNull(adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, "mail")); | |
131 | + ((ObjectNode) adminSettings.getJsonValue()).put("password", mailSettings.getJsonValue().get("password").asText()); | |
132 | + } | |
129 | 133 | String email = getCurrentUser().getEmail(); |
130 | 134 | mailService.sendTestMail(adminSettings.getJsonValue(), email); |
131 | 135 | } | ... | ... |
application/src/main/java/org/thingsboard/server/service/install/DefaultSystemDataLoaderService.java
... | ... | @@ -215,7 +215,7 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService { |
215 | 215 | node.put("password", ""); |
216 | 216 | node.put("tlsVersion", "TLSv1.2");//NOSONAR, key used to identify password field (not password value itself) |
217 | 217 | node.put("enableProxy", false); |
218 | - node.put("isDemo", true); | |
218 | + node.put("showChangePassword", false); | |
219 | 219 | mailSettings.setJsonValue(node); |
220 | 220 | adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, mailSettings); |
221 | 221 | } | ... | ... |
... | ... | @@ -126,10 +126,10 @@ |
126 | 126 | <input matInput formControlName="username" placeholder="{{ 'common.enter-username' | translate }}" |
127 | 127 | autocomplete="new-username"/> |
128 | 128 | </mat-form-field> |
129 | - <mat-checkbox *ngIf="!isDemo" formControlName="changePassword" style="padding-bottom: 16px;"> | |
129 | + <mat-checkbox *ngIf="showChangePassword" formControlName="changePassword" style="padding-bottom: 16px;"> | |
130 | 130 | {{ 'admin.change-password' | translate }} |
131 | 131 | </mat-checkbox> |
132 | - <mat-form-field class="mat-block" *ngIf="mailSettings.get('changePassword').value || isDemo"> | |
132 | + <mat-form-field class="mat-block" *ngIf="mailSettings.get('changePassword').value || !showChangePassword"> | |
133 | 133 | <mat-label translate>common.password</mat-label> |
134 | 134 | <input matInput formControlName="password" type="password" |
135 | 135 | placeholder="{{ 'common.enter-password' | translate }}" autocomplete="new-password"> | ... | ... |
... | ... | @@ -25,7 +25,7 @@ import { AdminService } from '@core/http/admin.service'; |
25 | 25 | import { ActionNotificationShow } from '@core/notification/notification.actions'; |
26 | 26 | import { TranslateService } from '@ngx-translate/core'; |
27 | 27 | import { HasConfirmForm } from '@core/guards/confirm-on-exit.guard'; |
28 | -import { deepClone, isString } from '@core/utils'; | |
28 | +import { isDefinedAndNotNull, isString } from '@core/utils'; | |
29 | 29 | import { Subject } from 'rxjs'; |
30 | 30 | import { takeUntil } from 'rxjs/operators'; |
31 | 31 | |
... | ... | @@ -39,7 +39,7 @@ export class MailServerComponent extends PageComponent implements OnInit, OnDest |
39 | 39 | mailSettings: FormGroup; |
40 | 40 | adminSettings: AdminSettings<MailServerSettings>; |
41 | 41 | smtpProtocols = ['smtp', 'smtps']; |
42 | - isDemo = true; | |
42 | + showChangePassword = false; | |
43 | 43 | |
44 | 44 | tlsVersions = ['TLSv1', 'TLSv1.1', 'TLSv1.2', 'TLSv1.3']; |
45 | 45 | |
... | ... | @@ -61,10 +61,11 @@ export class MailServerComponent extends PageComponent implements OnInit, OnDest |
61 | 61 | if (this.adminSettings.jsonValue && isString(this.adminSettings.jsonValue.enableTls)) { |
62 | 62 | this.adminSettings.jsonValue.enableTls = (this.adminSettings.jsonValue.enableTls as any) === 'true'; |
63 | 63 | } |
64 | - this.isDemo = this.adminSettings.jsonValue.isDemo; | |
65 | - delete this.adminSettings.jsonValue.isDemo; | |
64 | + this.showChangePassword = | |
65 | + isDefinedAndNotNull(this.adminSettings.jsonValue.showChangePassword) ? this.adminSettings.jsonValue.showChangePassword : true ; | |
66 | + delete this.adminSettings.jsonValue.showChangePassword; | |
66 | 67 | this.mailSettings.reset(this.adminSettings.jsonValue); |
67 | - this.enableMailPassword(this.isDemo); | |
68 | + this.enableMailPassword(!this.showChangePassword); | |
68 | 69 | this.enableProxyChanged(); |
69 | 70 | } |
70 | 71 | ); |
... | ... | @@ -147,11 +148,9 @@ export class MailServerComponent extends PageComponent implements OnInit, OnDest |
147 | 148 | this.adminSettings.jsonValue = {...this.adminSettings.jsonValue, ...this.mailSettingsFormValue}; |
148 | 149 | this.adminService.saveAdminSettings(this.adminSettings).subscribe( |
149 | 150 | (adminSettings) => { |
150 | - adminSettings.jsonValue.password = this.mailSettings.value.password; | |
151 | 151 | this.adminSettings = adminSettings; |
152 | - const formSettings = deepClone(this.adminSettings.jsonValue); | |
153 | - formSettings.changePassword = this.mailSettings.get('changePassword').value || this.isDemo; | |
154 | - this.mailSettings.reset(formSettings, {emitEvent: false}); | |
152 | + this.showChangePassword = true; | |
153 | + this.mailSettings.reset(this.adminSettings.jsonValue); | |
155 | 154 | } |
156 | 155 | ); |
157 | 156 | } | ... | ... |
... | ... | @@ -27,7 +27,7 @@ export interface AdminSettings<T> { |
27 | 27 | export declare type SmtpProtocol = 'smtp' | 'smtps'; |
28 | 28 | |
29 | 29 | export interface MailServerSettings { |
30 | - isDemo: boolean; | |
30 | + showChangePassword: boolean; | |
31 | 31 | mailFrom: string; |
32 | 32 | smtpProtocol: SmtpProtocol; |
33 | 33 | smtpHost: string; | ... | ... |