Browse Source

improvement of solution

pull/4179/head
AndrewVolosytnykhThingsboard 6 years ago
parent
commit
8ea3dcb808
  1. 1
      application/src/main/java/org/thingsboard/server/controller/AuthController.java
  2. 4
      ui-ngx/src/app/modules/home/pages/user/user.component.html
  3. 9
      ui-ngx/src/app/modules/home/pages/user/user.component.ts

1
application/src/main/java/org/thingsboard/server/controller/AuthController.java

@ -215,6 +215,7 @@ public class AuthController extends BaseController {
User user = userService.findUserById(TenantId.SYS_TENANT_ID, credentials.getUserId());
UserPrincipal principal = new UserPrincipal(UserPrincipal.Type.USER_NAME, user.getEmail());
SecurityUser securityUser = new SecurityUser(user, credentials.isEnabled(), principal);
userService.setUserCredentialsEnabled(user.getTenantId(), user.getId(), true);
String baseUrl = systemSecurityService.getBaseUrl(user.getTenantId(), user.getCustomerId(), request);
String loginUrl = String.format("%s/login", baseUrl);
String email = user.getEmail();

4
ui-ngx/src/app/modules/home/pages/user/user.component.html

@ -19,13 +19,13 @@
<button mat-raised-button color="primary"
[disabled]="(isLoading$ | async)"
(click)="onEntityAction($event, 'disableAccount')"
[fxShow]="!isEdit && isUserCredentialsEnabled()">
[fxShow]="!isEdit && isUserCredentialPresent() && isUserCredentialsEnabled()">
{{'user.disable-account' | translate }}
</button>
<button mat-raised-button color="primary"
[disabled]="(isLoading$ | async)"
(click)="onEntityAction($event, 'enableAccount')"
[fxShow]="!isEdit && !isUserCredentialsEnabled()">
[fxShow]="!isEdit && isUserCredentialPresent() && !isUserCredentialsEnabled()">
{{'user.enable-account' | translate }}
</button>
<button mat-raised-button color="primary"

9
ui-ngx/src/app/modules/home/pages/user/user.component.ts

@ -56,11 +56,12 @@ export class UserComponent extends EntityComponent<User> {
}
isUserCredentialsEnabled(): boolean {
if (!this.entity || !this.entity.additionalInfo || isUndefined(this.entity.additionalInfo.userCredentialsEnabled)) {
return true;
} else {
return this.entity.additionalInfo.userCredentialsEnabled === true;
}
}
isUserCredentialPresent(): boolean {
return !(!this.entity || !this.entity.additionalInfo || isUndefined(this.entity.additionalInfo.userCredentialsEnabled));
}
buildForm(entity: User): FormGroup {

Loading…
Cancel
Save