TSK-473 Redirect web application to no access when REST service is not present
This commit is contained in:
parent
cdcaa6b2fe
commit
670faba7f5
|
@ -74,7 +74,7 @@ const DECLARATIONS = [
|
|||
|
||||
export function startupServiceFactory(startupService: StartupService): () => Promise<any> {
|
||||
return (): Promise<any> => {
|
||||
return startupService.load();
|
||||
return startupService.load()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="user-info white">
|
||||
<span>Logged as: {{userInformation.userId}}</span>
|
||||
<span>Logged as: {{userInformation?.userId}}</span>
|
||||
<button type="button" class="btn btn-default white pull-right transparent" (click)="toogleRoles();" aria-expanded="true" aria-controls="roles">
|
||||
<span>Roles</span>
|
||||
</button>
|
||||
|
|
|
@ -29,7 +29,9 @@ export class UserInformationComponent implements OnInit {
|
|||
|
||||
ngOnInit() {
|
||||
this.userInformation = this.taskanaEngineService.currentUserInfo;
|
||||
this.roles = '[' + this.taskanaEngineService.currentUserInfo.roles.join(',') + ']';
|
||||
if (this.userInformation) {
|
||||
this.roles = '[' + this.userInformation.roles.join(',') + ']';
|
||||
}
|
||||
}
|
||||
|
||||
toogleRoles() {
|
||||
|
|
|
@ -11,7 +11,7 @@ export class DomainGuard implements CanActivate {
|
|||
constructor(private domainService: DomainService, private errorModalService: ErrorModalService) { }
|
||||
|
||||
canActivate() {
|
||||
return this.domainService.getDomains().map(domain => {
|
||||
return this.domainService.getDomains(true).map(domain => {
|
||||
return true;
|
||||
}).catch(() => {
|
||||
this.errorModalService.triggerError(new ErrorModel(
|
||||
|
|
|
@ -11,7 +11,7 @@ import { WindowRefService } from 'app/services/window/window.service';
|
|||
@Injectable()
|
||||
export class UserGuard implements CanActivate {
|
||||
static roles = ['ADMIN', 'USER'];
|
||||
constructor(private taskanaEngineService: TaskanaEngineService, public router: Router) { }
|
||||
constructor(private taskanaEngineService: TaskanaEngineService, private router: Router) { }
|
||||
canActivate() {
|
||||
if (this.taskanaEngineService.hasRole(UserGuard.roles)) {
|
||||
return true;
|
||||
|
|
|
@ -26,7 +26,7 @@ export class DomainService {
|
|||
|
||||
// GET
|
||||
getDomains(forceRefresh = false): Observable<string[]> {
|
||||
if (!this.dataObs$.observers.length || forceRefresh) {
|
||||
if (forceRefresh) {
|
||||
this.httpClient.get<string[]>(this.url).subscribe(
|
||||
domains => {
|
||||
this.dataObs$.next(domains);
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
import { Observable } from 'rxjs/Observable';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { CanActivate } from '@angular/router';
|
||||
import { Router } from '@angular/router';
|
||||
import { environment } from 'app/../environments/environment';
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
import { Injectable, Inject, Injector } from '@angular/core';
|
||||
import { TitlesService } from 'app/services/titles/titles.service';
|
||||
import { CustomFieldsService } from 'app/services/custom-fields/custom-fields.service';
|
||||
import { TaskanaEngineService } from 'app/services/taskana-engine/taskana-engine.service';
|
||||
|
||||
@Injectable()
|
||||
export class StartupService {
|
||||
|
||||
|
@ -14,7 +15,8 @@ export class StartupService {
|
|||
private httpClient: HttpClient,
|
||||
private titlesService: TitlesService,
|
||||
private customFieldsService: CustomFieldsService,
|
||||
private taskanaEngineService: TaskanaEngineService) { }
|
||||
private taskanaEngineService: TaskanaEngineService,
|
||||
private injector: Injector) { }
|
||||
|
||||
load(): Promise<any> {
|
||||
return this.loadEnvironment();
|
||||
|
@ -25,7 +27,9 @@ export class StartupService {
|
|||
() => this.geCustomizedFieldsFilePromise()
|
||||
).then(
|
||||
() => this.taskanaEngineService.getUserInformation()
|
||||
)
|
||||
).catch(error => {
|
||||
this.router.navigate(['no-role']);
|
||||
});
|
||||
}
|
||||
|
||||
getEnvironmentFilePromise() {
|
||||
|
@ -51,4 +55,8 @@ export class StartupService {
|
|||
return Observable.of(true)
|
||||
});
|
||||
}
|
||||
|
||||
public get router(): Router {
|
||||
return this.injector.get(Router);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue