Commit 5e2c06700e460a01df5ec8c1d94eec30aea07046
Committed by
GitHub
Merge pull request #3326 from YevhenBondarenko/develop/2.5.4-mail
smtp password
Showing
3 changed files
with
18 additions
and
4 deletions
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.controller; |
17 | 17 | |
18 | +import com.fasterxml.jackson.databind.node.ObjectNode; | |
18 | 19 | import org.springframework.beans.factory.annotation.Autowired; |
19 | 20 | import org.springframework.security.access.prepost.PreAuthorize; |
20 | 21 | import org.springframework.web.bind.annotation.PathVariable; |
... | ... | @@ -59,7 +60,11 @@ public class AdminController extends BaseController { |
59 | 60 | public AdminSettings getAdminSettings(@PathVariable("key") String key) throws ThingsboardException { |
60 | 61 | try { |
61 | 62 | accessControlService.checkPermission(getCurrentUser(), Resource.ADMIN_SETTINGS, Operation.READ); |
62 | - return checkNotNull(adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, key)); | |
63 | + AdminSettings adminSettings = checkNotNull(adminSettingsService.findAdminSettingsByKey(TenantId.SYS_TENANT_ID, key)); | |
64 | + if (adminSettings.getKey().equals("mail")) { | |
65 | + ((ObjectNode) adminSettings.getJsonValue()).put("password", ""); | |
66 | + } | |
67 | + return adminSettings; | |
63 | 68 | } catch (Exception e) { |
64 | 69 | throw handleException(e); |
65 | 70 | } |
... | ... | @@ -74,6 +79,7 @@ public class AdminController extends BaseController { |
74 | 79 | adminSettings = checkNotNull(adminSettingsService.saveAdminSettings(TenantId.SYS_TENANT_ID, adminSettings)); |
75 | 80 | if (adminSettings.getKey().equals("mail")) { |
76 | 81 | mailService.updateMailConfiguration(); |
82 | + ((ObjectNode) adminSettings.getJsonValue()).put("password", ""); | |
77 | 83 | } |
78 | 84 | return adminSettings; |
79 | 85 | } catch (Exception e) { | ... | ... |
... | ... | @@ -15,6 +15,7 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.dao.settings; |
17 | 17 | |
18 | +import com.fasterxml.jackson.databind.node.ObjectNode; | |
18 | 19 | import lombok.extern.slf4j.Slf4j; |
19 | 20 | import org.apache.commons.lang3.StringUtils; |
20 | 21 | import org.springframework.beans.factory.annotation.Autowired; |
... | ... | @@ -52,6 +53,13 @@ public class AdminSettingsServiceImpl implements AdminSettingsService { |
52 | 53 | public AdminSettings saveAdminSettings(TenantId tenantId, AdminSettings adminSettings) { |
53 | 54 | log.trace("Executing saveAdminSettings [{}]", adminSettings); |
54 | 55 | adminSettingsValidator.validate(adminSettings, data -> tenantId); |
56 | + if (adminSettings.getKey().equals("mail") && "".equals(adminSettings.getJsonValue().get("password").asText())) { | |
57 | + AdminSettings mailSettings = findAdminSettingsByKey(tenantId, "mail"); | |
58 | + if (mailSettings != null) { | |
59 | + ((ObjectNode) adminSettings.getJsonValue()).put("password", mailSettings.getJsonValue().get("password").asText()); | |
60 | + } | |
61 | + } | |
62 | + | |
55 | 63 | return adminSettingsDao.save(tenantId, adminSettings); |
56 | 64 | } |
57 | 65 | ... | ... |
... | ... | @@ -123,16 +123,16 @@ |
123 | 123 | </md-input-container> |
124 | 124 | <md-input-container class="md-block"> |
125 | 125 | <label translate>admin.proxy-password</label> |
126 | - <input name="proxyPassword" ng-model="vm.settings.jsonValue.proxyPassword"> | |
126 | + <input name="proxyPassword" type="password" autocomplete="new-password" ng-model="vm.settings.jsonValue.proxyPassword"> | |
127 | 127 | </md-input-container> |
128 | 128 | </section> |
129 | 129 | <md-input-container class="md-block"> |
130 | 130 | <label translate>common.username</label> |
131 | - <input name="username" placeholder="{{ 'common.enter-username' | translate }}" ng-model="vm.settings.jsonValue.username"> | |
131 | + <input placeholder="{{ 'common.enter-username' | translate }}" ng-model="vm.settings.jsonValue.username" autocomplete="new-username" > | |
132 | 132 | </md-input-container> |
133 | 133 | <md-input-container class="md-block"> |
134 | 134 | <label translate>common.password</label> |
135 | - <input name="password" placeholder="{{ 'common.enter-password' | translate }}" type="password" ng-model="vm.settings.jsonValue.password"> | |
135 | + <input placeholder="{{ 'common.enter-password' | translate }}" type="password" ng-model="vm.settings.jsonValue.password" autocomplete="new-password"> | |
136 | 136 | </md-input-container> |
137 | 137 | <div layout="row" layout-align="end center" width="100%" layout-wrap> |
138 | 138 | <md-button ng-disabled="$root.loading || vm.settingsForm.$invalid" ng-click="vm.sendTestMail()" class="md-raised">{{'admin.send-test-mail' | translate}}</md-button> | ... | ... |