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) {}
|
constructor(private router: Router) {}
|
||||||
|
|
||||||
check(route: Route) : boolean{
|
check(path: string) : boolean{
|
||||||
let loggedIn = false;
|
let loggedIn = false;
|
||||||
let isAdmin = false;
|
let isAdmin = false;
|
||||||
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||||
|
@ -21,18 +21,16 @@ export class AdminLoginGuard implements CanActivate, CanLoad {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!loggedIn || !isAdmin) {
|
if(!loggedIn || !isAdmin) {
|
||||||
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
this.router.navigate(['/user-info'], {queryParams: {"errorCode": errorCode, "redirectUrl": path}});
|
||||||
route.path = '/' + route.path;
|
|
||||||
this.router.navigate(['user-info'], {queryParams: {"errorCode": errorCode, "redirectUrl": route.path}});
|
|
||||||
}
|
}
|
||||||
return loggedIn && isAdmin;
|
return loggedIn && isAdmin;
|
||||||
}
|
}
|
||||||
|
|
||||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
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 {
|
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) {}
|
constructor(private router: Router) {}
|
||||||
|
|
||||||
check(route: Route) : boolean{
|
check(path: string) : boolean{
|
||||||
//var user;
|
//var user;
|
||||||
//var role = route.data['role']
|
//var role = route.data['role']
|
||||||
let loggedIn = false;
|
let loggedIn = false;
|
||||||
|
@ -27,17 +27,16 @@ export class ClaimsCuratorGuard implements CanActivate, CanLoad {
|
||||||
}
|
}
|
||||||
if(!loggedIn || !isAuthorized){
|
if(!loggedIn || !isAuthorized){
|
||||||
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
||||||
route.path = '/' + route.path;
|
this.router.navigate(['/user-info'], {queryParams: {"errorCode": errorCode, "redirectUrl": path}});
|
||||||
this.router.navigate(['user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": route.path } });
|
|
||||||
}
|
}
|
||||||
return loggedIn && isAuthorized;
|
return loggedIn && isAuthorized;
|
||||||
}
|
}
|
||||||
|
|
||||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
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 {
|
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) {}
|
constructor(private router: Router) {}
|
||||||
|
|
||||||
check(route: Route):boolean {
|
check(path: string) :boolean {
|
||||||
//var user;
|
//var user;
|
||||||
let valid = true;
|
let valid = true;
|
||||||
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||||
if(!valid){
|
if(!valid){
|
||||||
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
this.router.navigate(['/user-info'], {queryParams: {"errorCode": errorCode, "redirectUrl": path}});
|
||||||
route.path = '/' + route.path;
|
|
||||||
this.router.navigate(['user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": route.path } });
|
|
||||||
}
|
}
|
||||||
return valid;
|
return valid;
|
||||||
}
|
}
|
||||||
|
|
||||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
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 {
|
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) {}
|
constructor(private router: Router) {}
|
||||||
|
|
||||||
check(route: Route): boolean{
|
check(path: string): boolean{
|
||||||
//var user;
|
//var user;
|
||||||
let loggedIn = false;
|
let loggedIn = false;
|
||||||
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
let errorCode = LoginErrorCodes.NOT_LOGIN;
|
||||||
|
@ -19,17 +19,16 @@ export class LoginGuard implements CanActivate, CanLoad {
|
||||||
}
|
}
|
||||||
if(!loggedIn){
|
if(!loggedIn){
|
||||||
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
// this.guardHelper.redirect("/user-info",errorCode,state.url);
|
||||||
route.path = '/' + route.path;
|
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, path} });
|
||||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": errorCode, "redirectUrl": route.path } });
|
|
||||||
}
|
}
|
||||||
return loggedIn;
|
return loggedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | boolean {
|
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 {
|
canLoad(route: Route): Observable<boolean> | Promise<boolean> | boolean {
|
||||||
return this.check(route);
|
return this.check('/' + route.path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue