login with the default tenant

This commit is contained in:
Sofia Papacharalampous 2024-04-04 13:50:51 +03:00
parent 8cec0c3552
commit 5decf6f4b1
3 changed files with 9 additions and 8 deletions

View File

@ -272,7 +272,7 @@ export class AuthService extends BaseService {
})
.catch((error) => this.onAuthenticateError(error));
} else {
this.zone.run(() => this.router.navigate(['/login/post']));
this.zone.run(() => this.router.navigate([returnUrl]));
}
});
}

View File

@ -29,22 +29,23 @@ export class LoginComponent extends BaseComponent implements OnInit {
) { super(); }
ngOnInit(): void {
this.returnUrl = this.route.snapshot.queryParamMap.get('returnUrl') || '/login/post';
this.returnUrl = this.route.snapshot.queryParamMap.get('returnUrl') || '/';
this.keycloakService.isLoggedIn().then(isLoggedIn => {
if (!isLoggedIn) {
this.authService.authenticate('/login/post');
this.authService.authenticate('/');
} else {
this.authService.prepareAuthRequest(from(this.keycloakService.getToken())).pipe(takeUntil(this._destroyed)).subscribe(
() => {
let returnUrL = this.returnUrl;
let queryParams: Params = {};
if(!this.authService.selectedTenant()){
returnUrL = '/login/post';
queryParams.returnUrl = this.returnUrl;
this.authService.selectedTenant('default');
// returnUrL = '/login/post';
// queryParams.returnUrl = this.returnUrl;
}
this.zone.run(() => this.router.navigate([returnUrL],{queryParams} ));
},
(error) => this.authService.authenticate('/login/post') );
(error) => this.authService.authenticate('/') );
}

View File

@ -21,8 +21,8 @@ export class StatusCodeInterceptor extends BaseInterceptor {
}
const error: HttpError = this.httpErrorHandlingService.getError(err);
if (error.statusCode === 403 && error.errorCode === 103) {
this.authService.selectedTenant(null);
this.router.navigate(['/login/post']);
this.authService.selectedTenant('default');
this.router.navigate(['/']);
}
}));
}