You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @nnixaa , I already change to onAuthenticationChange in my AuthGuard like below code to return the Observable but it always go to true even I haven't logged-in. Could you please give me the hint for this login problem?
import { Observable } from 'rxjs/Observable';
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '';
import { Injectable } from '';
import { NbAuthService, NbTokenService } from '';
@Injectable()
export class CanActivateAuthGuard implements CanActivate {
Hi @nnixaa , I already change to onAuthenticationChange in my AuthGuard like below code to return the Observable but it always go to true even I haven't logged-in. Could you please give me the hint for this login problem?
import { Observable } from 'rxjs/Observable';
import { Router, CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot } from '';
import { Injectable } from '';
import { NbAuthService, NbTokenService } from '';
@Injectable()
export class CanActivateAuthGuard implements CanActivate {
constructor(private router: Router, private nbAuthService: NbAuthService,
private tokenService: NbTokenService) {}
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
return this.nbAuthService.onAuthenticationChange().map(
result => {
console.log("logged-in with result", result);
if (result) return true;
}
).catch(() => {
this.router.navigate(['/auth/login']);
console.log("not yet logged-in")
return Observable.of(false);
});
}
}
Best regards
The text was updated successfully, but these errors were encountered: