Showing
3 changed files
with
8 additions
and
6 deletions
@@ -215,6 +215,7 @@ public class AuthController extends BaseController { | @@ -215,6 +215,7 @@ public class AuthController extends BaseController { | ||
215 | User user = userService.findUserById(TenantId.SYS_TENANT_ID, credentials.getUserId()); | 215 | User user = userService.findUserById(TenantId.SYS_TENANT_ID, credentials.getUserId()); |
216 | UserPrincipal principal = new UserPrincipal(UserPrincipal.Type.USER_NAME, user.getEmail()); | 216 | UserPrincipal principal = new UserPrincipal(UserPrincipal.Type.USER_NAME, user.getEmail()); |
217 | SecurityUser securityUser = new SecurityUser(user, credentials.isEnabled(), principal); | 217 | SecurityUser securityUser = new SecurityUser(user, credentials.isEnabled(), principal); |
218 | + userService.setUserCredentialsEnabled(user.getTenantId(), user.getId(), true); | ||
218 | String baseUrl = systemSecurityService.getBaseUrl(user.getTenantId(), user.getCustomerId(), request); | 219 | String baseUrl = systemSecurityService.getBaseUrl(user.getTenantId(), user.getCustomerId(), request); |
219 | String loginUrl = String.format("%s/login", baseUrl); | 220 | String loginUrl = String.format("%s/login", baseUrl); |
220 | String email = user.getEmail(); | 221 | String email = user.getEmail(); |
@@ -19,13 +19,13 @@ | @@ -19,13 +19,13 @@ | ||
19 | <button mat-raised-button color="primary" | 19 | <button mat-raised-button color="primary" |
20 | [disabled]="(isLoading$ | async)" | 20 | [disabled]="(isLoading$ | async)" |
21 | (click)="onEntityAction($event, 'disableAccount')" | 21 | (click)="onEntityAction($event, 'disableAccount')" |
22 | - [fxShow]="!isEdit && isUserCredentialsEnabled()"> | 22 | + [fxShow]="!isEdit && isUserCredentialPresent() && isUserCredentialsEnabled()"> |
23 | {{'user.disable-account' | translate }} | 23 | {{'user.disable-account' | translate }} |
24 | </button> | 24 | </button> |
25 | <button mat-raised-button color="primary" | 25 | <button mat-raised-button color="primary" |
26 | [disabled]="(isLoading$ | async)" | 26 | [disabled]="(isLoading$ | async)" |
27 | (click)="onEntityAction($event, 'enableAccount')" | 27 | (click)="onEntityAction($event, 'enableAccount')" |
28 | - [fxShow]="!isEdit && !isUserCredentialsEnabled()"> | 28 | + [fxShow]="!isEdit && isUserCredentialPresent() && !isUserCredentialsEnabled()"> |
29 | {{'user.enable-account' | translate }} | 29 | {{'user.enable-account' | translate }} |
30 | </button> | 30 | </button> |
31 | <button mat-raised-button color="primary" | 31 | <button mat-raised-button color="primary" |
@@ -56,11 +56,12 @@ export class UserComponent extends EntityComponent<User> { | @@ -56,11 +56,12 @@ export class UserComponent extends EntityComponent<User> { | ||
56 | } | 56 | } |
57 | 57 | ||
58 | isUserCredentialsEnabled(): boolean { | 58 | isUserCredentialsEnabled(): boolean { |
59 | - if (!this.entity || !this.entity.additionalInfo || isUndefined(this.entity.additionalInfo.userCredentialsEnabled)) { | ||
60 | - return true; | ||
61 | - } else { | ||
62 | return this.entity.additionalInfo.userCredentialsEnabled === true; | 59 | return this.entity.additionalInfo.userCredentialsEnabled === true; |
63 | - } | 60 | + } |
61 | + | ||
62 | + isUserCredentialPresent(): boolean { | ||
63 | + return !(!this.entity || !this.entity.additionalInfo || isUndefined(this.entity.additionalInfo.userCredentialsEnabled)); | ||
64 | + | ||
64 | } | 65 | } |
65 | 66 | ||
66 | buildForm(entity: User): FormGroup { | 67 | buildForm(entity: User): FormGroup { |