Revert Guards to Can Activate
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@54665 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
e73b632bc3
commit
a2fed50ea1
|
@ -9,7 +9,7 @@ export class AdminLoginGuard implements CanActivate, CanLoad {
|
|||
|
||||
constructor(private router: Router) {}
|
||||
|
||||
check(route: Route) : boolean{
|
||||
check(path: string) : boolean{
|
||||
let loggedIn = false;
|
||||
let isAdmin = false;
|
||||
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||
|
@ -21,18 +21,16 @@ export class AdminLoginGuard implements CanActivate, CanLoad {
|
|||
}
|
||||
}
|
||||
if(!loggedIn || !isAdmin) {
|
||||
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
||||
route.path = '/' + route.path;
|
||||
this.router.navigate(['user-info'], {queryParams: {"errorCode": errorCode, "redirectUrl": route.path}});
|
||||
this.router.navigate(['/user-info'], {queryParams: {"errorCode": errorCode, "redirectUrl": path}});
|
||||
}
|
||||
return loggedIn && isAdmin;
|
||||
}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
return this.check(route.routeConfig);
|
||||
return this.check(state.url);
|
||||
}
|
||||
|
||||
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
|
||||
return this.check(route);
|
||||
return this.check('/' + route.path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ export class ClaimsCuratorGuard implements CanActivate, CanLoad {
|
|||
|
||||
constructor(private router: Router) {}
|
||||
|
||||
check(route: Route) : boolean{
|
||||
check(path: string) : boolean{
|
||||
//var user;
|
||||
//var role = route.data['role']
|
||||
let loggedIn = false;
|
||||
|
@ -27,17 +27,16 @@ export class ClaimsCuratorGuard implements CanActivate, CanLoad {
|
|||
}
|
||||
if(!loggedIn || !isAuthorized){
|
||||
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
||||
route.path = '/' + route.path;
|
||||
this.router.navigate(['user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": route.path } });
|
||||
this.router.navigate(['/user-info'], {queryParams: {"errorCode": errorCode, "redirectUrl": path}});
|
||||
}
|
||||
return loggedIn && isAuthorized;
|
||||
}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
return this.check(route.routeConfig);
|
||||
return this.check(state.url);
|
||||
}
|
||||
|
||||
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
|
||||
return this.check(route);
|
||||
return this.check('/' + route.path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,23 +16,21 @@ export class FreeGuard implements CanActivate, CanLoad{
|
|||
|
||||
constructor(private router: Router) {}
|
||||
|
||||
check(route: Route):boolean {
|
||||
check(path: string) :boolean {
|
||||
//var user;
|
||||
let valid = true;
|
||||
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||
if(!valid){
|
||||
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
||||
route.path = '/' + route.path;
|
||||
this.router.navigate(['user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": route.path } });
|
||||
this.router.navigate(['/user-info'], {queryParams: {"errorCode": errorCode, "redirectUrl": path}});
|
||||
}
|
||||
return valid;
|
||||
}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
return this.check(route.routeConfig);
|
||||
return this.check(state.url);
|
||||
}
|
||||
|
||||
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
|
||||
return this.check(route);
|
||||
return this.check('/' + route.path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ export class LoginGuard implements CanActivate, CanLoad {
|
|||
|
||||
constructor(private router: Router) {}
|
||||
|
||||
check(route: Route): boolean{
|
||||
check(path: string): boolean{
|
||||
//var user;
|
||||
let loggedIn = false;
|
||||
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||
|
@ -19,17 +19,16 @@ export class LoginGuard implements CanActivate, CanLoad {
|
|||
}
|
||||
if(!loggedIn){
|
||||
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
||||
route.path = '/' + route.path;
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": route.path } });
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, path} });
|
||||
}
|
||||
return loggedIn;
|
||||
}
|
||||
|
||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
||||
return this.check(route.routeConfig);
|
||||
return this.check(state.url);
|
||||
}
|
||||
|
||||
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
|
||||
return this.check(route);
|
||||
return this.check('/' + route.path);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue