Commit fe7374f21d0b03f07a148f6804130f2198c72918
1 parent
5d8d1928
Correct processing requests and sending response
Showing
6 changed files
with
13 additions
and
12 deletions
... | ... | @@ -26,12 +26,12 @@ import org.springframework.web.bind.annotation.ResponseBody; |
26 | 26 | import org.springframework.web.bind.annotation.RestController; |
27 | 27 | import org.thingsboard.rule.engine.api.MailService; |
28 | 28 | import org.thingsboard.rule.engine.api.SmsService; |
29 | -import org.thingsboard.server.common.data.sms.config.TestSmsRequest; | |
30 | 29 | import org.thingsboard.server.common.data.AdminSettings; |
31 | 30 | import org.thingsboard.server.common.data.UpdateMessage; |
32 | 31 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
33 | 32 | import org.thingsboard.server.common.data.id.TenantId; |
34 | 33 | import org.thingsboard.server.common.data.security.model.SecuritySettings; |
34 | +import org.thingsboard.server.common.data.sms.config.TestSmsRequest; | |
35 | 35 | import org.thingsboard.server.dao.settings.AdminSettingsService; |
36 | 36 | import org.thingsboard.server.queue.util.TbCoreComponent; |
37 | 37 | import org.thingsboard.server.service.security.permission.Operation; |
... | ... | @@ -67,7 +67,7 @@ public class AdminController extends BaseController { |
67 | 67 | accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.READ); |
68 | 68 | AdminSettings adminSettings = checkNotNull(adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, key)); |
69 | 69 | if (adminSettings.getKey().equals("mail")) { |
70 | - ((ObjectNode) adminSettings.getJsonValue()).put("password", ""); | |
70 | + ((ObjectNode) adminSettings.getJsonValue()).remove("password"); | |
71 | 71 | } |
72 | 72 | return adminSettings; |
73 | 73 | } catch (Exception e) { |
... | ... | @@ -84,7 +84,7 @@ public class AdminController extends BaseController { |
84 | 84 | adminSettings = checkNotNull(adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, adminSettings)); |
85 | 85 | if (adminSettings.getKey().equals("mail")) { |
86 | 86 | mailService.updateMailConfiguration(); |
87 | - ((ObjectNode) adminSettings.getJsonValue()).put("password", ""); | |
87 | + ((ObjectNode) adminSettings.getJsonValue()).remove("password"); | |
88 | 88 | } else if (adminSettings.getKey().equals("sms")) { |
89 | 89 | smsService.updateSmsConfiguration(); |
90 | 90 | } | ... | ... |
application/src/main/java/org/thingsboard/server/service/install/DefaultSystemDataLoaderService.java
... | ... | @@ -215,6 +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 | 219 | mailSettings.setJsonValue(node); |
219 | 220 | adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, mailSettings); |
220 | 221 | } | ... | ... |
... | ... | @@ -52,7 +52,7 @@ public class AdminSettingsServiceImpl implements AdminSettingsService { |
52 | 52 | public AdminSettings saveAdminSettings(TenantId tenantId, AdminSettings adminSettings) { |
53 | 53 | log.trace("Executing saveAdminSettings [{}]", adminSettings); |
54 | 54 | adminSettingsValidator.validate(adminSettings, data -> tenantId); |
55 | - if (adminSettings.getKey().equals("mail") && "".equals(adminSettings.getJsonValue().get("password").asText())) { | |
55 | + if(adminSettings.getKey().equals("mail") && !adminSettings.getJsonValue().has("password")) { | |
56 | 56 | AdminSettings mailSettings = findAdminSettingsByKey(tenantId, "mail"); |
57 | 57 | if (mailSettings != null) { |
58 | 58 | ((ObjectNode) adminSettings.getJsonValue()).put("password", mailSettings.getJsonValue().get("password").asText()); |
... | ... | @@ -61,7 +61,7 @@ public class AdminSettingsServiceImpl implements AdminSettingsService { |
61 | 61 | |
62 | 62 | return adminSettingsDao.save(tenantId, adminSettings); |
63 | 63 | } |
64 | - | |
64 | + | |
65 | 65 | private DataValidator<AdminSettings> adminSettingsValidator = |
66 | 66 | new DataValidator<AdminSettings>() { |
67 | 67 | ... | ... |
... | ... | @@ -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="!isAdd" formControlName="changePassword" style="padding-bottom: 16px;"> | |
129 | + <mat-checkbox *ngIf="!isDemo" 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 || isAdd"> | |
132 | + <mat-form-field class="mat-block" *ngIf="mailSettings.get('changePassword').value || isDemo"> | |
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"> | ... | ... |
... | ... | @@ -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 | - isAdd = true; | |
42 | + isDemo = true; | |
43 | 43 | |
44 | 44 | tlsVersions = ['TLSv1', 'TLSv1.1', 'TLSv1.2', 'TLSv1.3']; |
45 | 45 | |
... | ... | @@ -61,10 +61,10 @@ 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.isAdd = this.adminSettings.jsonValue.isAdd; | |
65 | - delete this.adminSettings.jsonValue.isAdd; | |
64 | + this.isDemo = this.adminSettings.jsonValue.isDemo; | |
65 | + delete this.adminSettings.jsonValue.isDemo; | |
66 | 66 | this.mailSettings.reset(this.adminSettings.jsonValue); |
67 | - this.enableMailPassword(this.isAdd); | |
67 | + this.enableMailPassword(this.isDemo); | |
68 | 68 | this.enableProxyChanged(); |
69 | 69 | } |
70 | 70 | ); | ... | ... |
... | ... | @@ -27,7 +27,7 @@ export interface AdminSettings<T> { |
27 | 27 | export declare type SmtpProtocol = 'smtp' | 'smtps'; |
28 | 28 | |
29 | 29 | export interface MailServerSettings { |
30 | - isAdd: boolean; | |
30 | + isDemo: boolean; | |
31 | 31 | mailFrom: string; |
32 | 32 | smtpProtocol: SmtpProtocol; |
33 | 33 | smtpHost: string; | ... | ... |