src/guards/is-guest-user.guard.ts
Methods |
|
constructor(authService: AuthService, router: Router)
|
|||||||||
Defined in src/guards/is-guest-user.guard.ts:6
|
|||||||||
Parameters :
|
Async canLoad |
canLoad()
|
Defined in src/guards/is-guest-user.guard.ts:13
|
Returns :
Promise<boolean>
|
import { Injectable, Inject } from '@angular/core';
import { CanLoad, Router } from '@angular/router';
import { AuthService } from 'sunbird-sdk';
@Injectable()
export class IsGuestUserGuard implements CanLoad {
constructor(
@Inject('AUTH_SERVICE') private authService: AuthService,
private router: Router
) {
}
async canLoad(): Promise<boolean> {
if (!(await this.authService.getSession().toPromise())) {
return true;
}
this.router.navigate(['/', 'profile-settings']);
return false;
}
}