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,12 +26,12 @@ import org.springframework.web.bind.annotation.ResponseBody; | ||
26 | import org.springframework.web.bind.annotation.RestController; | 26 | import org.springframework.web.bind.annotation.RestController; |
27 | import org.thingsboard.rule.engine.api.MailService; | 27 | import org.thingsboard.rule.engine.api.MailService; |
28 | import org.thingsboard.rule.engine.api.SmsService; | 28 | import org.thingsboard.rule.engine.api.SmsService; |
29 | -import org.thingsboard.server.common.data.sms.config.TestSmsRequest; | ||
30 | import org.thingsboard.server.common.data.AdminSettings; | 29 | import org.thingsboard.server.common.data.AdminSettings; |
31 | import org.thingsboard.server.common.data.UpdateMessage; | 30 | import org.thingsboard.server.common.data.UpdateMessage; |
32 | import org.thingsboard.server.common.data.exception.ThingsboardException; | 31 | import org.thingsboard.server.common.data.exception.ThingsboardException; |
33 | import org.thingsboard.server.common.data.id.TenantId; | 32 | import org.thingsboard.server.common.data.id.TenantId; |
34 | import org.thingsboard.server.common.data.security.model.SecuritySettings; | 33 | import org.thingsboard.server.common.data.security.model.SecuritySettings; |
34 | +import org.thingsboard.server.common.data.sms.config.TestSmsRequest; | ||
35 | import org.thingsboard.server.dao.settings.AdminSettingsService; | 35 | import org.thingsboard.server.dao.settings.AdminSettingsService; |
36 | import org.thingsboard.server.queue.util.TbCoreComponent; | 36 | import org.thingsboard.server.queue.util.TbCoreComponent; |
37 | import org.thingsboard.server.service.security.permission.Operation; | 37 | import org.thingsboard.server.service.security.permission.Operation; |
@@ -67,7 +67,7 @@ public class AdminController extends BaseController { | @@ -67,7 +67,7 @@ public class AdminController extends BaseController { | ||
67 | accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.READ); | 67 | accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.READ); |
68 | AdminSettings adminSettings = checkNotNull(adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, key)); | 68 | AdminSettings adminSettings = checkNotNull(adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, key)); |
69 | if (adminSettings.getKey().equals("mail")) { | 69 | if (adminSettings.getKey().equals("mail")) { |
70 | - ((ObjectNode) adminSettings.getJsonValue()).put("password", ""); | 70 | + ((ObjectNode) adminSettings.getJsonValue()).remove("password"); |
71 | } | 71 | } |
72 | return adminSettings; | 72 | return adminSettings; |
73 | } catch (Exception e) { | 73 | } catch (Exception e) { |
@@ -84,7 +84,7 @@ public class AdminController extends BaseController { | @@ -84,7 +84,7 @@ public class AdminController extends BaseController { | ||
84 | adminSettings = checkNotNull(adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, adminSettings)); | 84 | adminSettings = checkNotNull(adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, adminSettings)); |
85 | if (adminSettings.getKey().equals("mail")) { | 85 | if (adminSettings.getKey().equals("mail")) { |
86 | mailService.updateMailConfiguration(); | 86 | mailService.updateMailConfiguration(); |
87 | - ((ObjectNode) adminSettings.getJsonValue()).put("password", ""); | 87 | + ((ObjectNode) adminSettings.getJsonValue()).remove("password"); |
88 | } else if (adminSettings.getKey().equals("sms")) { | 88 | } else if (adminSettings.getKey().equals("sms")) { |
89 | smsService.updateSmsConfiguration(); | 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,6 +215,7 @@ public class DefaultSystemDataLoaderService implements SystemDataLoaderService { | ||
215 | node.put("password", ""); | 215 | node.put("password", ""); |
216 | node.put("tlsVersion", "TLSv1.2");//NOSONAR, key used to identify password field (not password value itself) | 216 | node.put("tlsVersion", "TLSv1.2");//NOSONAR, key used to identify password field (not password value itself) |
217 | node.put("enableProxy", false); | 217 | node.put("enableProxy", false); |
218 | + node.put("isDemo", true); | ||
218 | mailSettings.setJsonValue(node); | 219 | mailSettings.setJsonValue(node); |
219 | adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, mailSettings); | 220 | adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, mailSettings); |
220 | } | 221 | } |
@@ -52,7 +52,7 @@ public class AdminSettingsServiceImpl implements AdminSettingsService { | @@ -52,7 +52,7 @@ public class AdminSettingsServiceImpl implements AdminSettingsService { | ||
52 | public AdminSettings saveAdminSettings(TenantId tenantId, AdminSettings adminSettings) { | 52 | public AdminSettings saveAdminSettings(TenantId tenantId, AdminSettings adminSettings) { |
53 | log.trace("Executing saveAdminSettings [{}]", adminSettings); | 53 | log.trace("Executing saveAdminSettings [{}]", adminSettings); |
54 | adminSettingsValidator.validate(adminSettings, data -> tenantId); | 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 | AdminSettings mailSettings = findAdminSettingsByKey(tenantId, "mail"); | 56 | AdminSettings mailSettings = findAdminSettingsByKey(tenantId, "mail"); |
57 | if (mailSettings != null) { | 57 | if (mailSettings != null) { |
58 | ((ObjectNode) adminSettings.getJsonValue()).put("password", mailSettings.getJsonValue().get("password").asText()); | 58 | ((ObjectNode) adminSettings.getJsonValue()).put("password", mailSettings.getJsonValue().get("password").asText()); |
@@ -61,7 +61,7 @@ public class AdminSettingsServiceImpl implements AdminSettingsService { | @@ -61,7 +61,7 @@ public class AdminSettingsServiceImpl implements AdminSettingsService { | ||
61 | 61 | ||
62 | return adminSettingsDao.save(tenantId, adminSettings); | 62 | return adminSettingsDao.save(tenantId, adminSettings); |
63 | } | 63 | } |
64 | - | 64 | + |
65 | private DataValidator<AdminSettings> adminSettingsValidator = | 65 | private DataValidator<AdminSettings> adminSettingsValidator = |
66 | new DataValidator<AdminSettings>() { | 66 | new DataValidator<AdminSettings>() { |
67 | 67 |
@@ -126,10 +126,10 @@ | @@ -126,10 +126,10 @@ | ||
126 | <input matInput formControlName="username" placeholder="{{ 'common.enter-username' | translate }}" | 126 | <input matInput formControlName="username" placeholder="{{ 'common.enter-username' | translate }}" |
127 | autocomplete="new-username"/> | 127 | autocomplete="new-username"/> |
128 | </mat-form-field> | 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 | {{ 'admin.change-password' | translate }} | 130 | {{ 'admin.change-password' | translate }} |
131 | </mat-checkbox> | 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 | <mat-label translate>common.password</mat-label> | 133 | <mat-label translate>common.password</mat-label> |
134 | <input matInput formControlName="password" type="password" | 134 | <input matInput formControlName="password" type="password" |
135 | placeholder="{{ 'common.enter-password' | translate }}" autocomplete="new-password"> | 135 | placeholder="{{ 'common.enter-password' | translate }}" autocomplete="new-password"> |
@@ -39,7 +39,7 @@ export class MailServerComponent extends PageComponent implements OnInit, OnDest | @@ -39,7 +39,7 @@ export class MailServerComponent extends PageComponent implements OnInit, OnDest | ||
39 | mailSettings: FormGroup; | 39 | mailSettings: FormGroup; |
40 | adminSettings: AdminSettings<MailServerSettings>; | 40 | adminSettings: AdminSettings<MailServerSettings>; |
41 | smtpProtocols = ['smtp', 'smtps']; | 41 | smtpProtocols = ['smtp', 'smtps']; |
42 | - isAdd = true; | 42 | + isDemo = true; |
43 | 43 | ||
44 | tlsVersions = ['TLSv1', 'TLSv1.1', 'TLSv1.2', 'TLSv1.3']; | 44 | tlsVersions = ['TLSv1', 'TLSv1.1', 'TLSv1.2', 'TLSv1.3']; |
45 | 45 | ||
@@ -61,10 +61,10 @@ export class MailServerComponent extends PageComponent implements OnInit, OnDest | @@ -61,10 +61,10 @@ export class MailServerComponent extends PageComponent implements OnInit, OnDest | ||
61 | if (this.adminSettings.jsonValue && isString(this.adminSettings.jsonValue.enableTls)) { | 61 | if (this.adminSettings.jsonValue && isString(this.adminSettings.jsonValue.enableTls)) { |
62 | this.adminSettings.jsonValue.enableTls = (this.adminSettings.jsonValue.enableTls as any) === 'true'; | 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 | this.mailSettings.reset(this.adminSettings.jsonValue); | 66 | this.mailSettings.reset(this.adminSettings.jsonValue); |
67 | - this.enableMailPassword(this.isAdd); | 67 | + this.enableMailPassword(this.isDemo); |
68 | this.enableProxyChanged(); | 68 | this.enableProxyChanged(); |
69 | } | 69 | } |
70 | ); | 70 | ); |
@@ -27,7 +27,7 @@ export interface AdminSettings<T> { | @@ -27,7 +27,7 @@ export interface AdminSettings<T> { | ||
27 | export declare type SmtpProtocol = 'smtp' | 'smtps'; | 27 | export declare type SmtpProtocol = 'smtp' | 'smtps'; |
28 | 28 | ||
29 | export interface MailServerSettings { | 29 | export interface MailServerSettings { |
30 | - isAdd: boolean; | 30 | + isDemo: boolean; |
31 | mailFrom: string; | 31 | mailFrom: string; |
32 | smtpProtocol: SmtpProtocol; | 32 | smtpProtocol: SmtpProtocol; |
33 | smtpHost: string; | 33 | smtpHost: string; |