>
> This is the solution:
>>>
>>>
import { Injectable } from '@angular/core';
import { CanActivate,
Router,
ActivatedRouteSnapshot,
RouterStateSnapshot } from '@angular/router';
import { AuthService } from './auth.service';
import {Observable} from 'rxjs/Observable';
@Injectable()
export class AuthGuard {
constructor(private _authService: AuthService, private _router: Router)
{}
canActivate(): Observable<boolean>{
return this._authService.checkIfUserIsLoggedIn()
.map((result) => {
console.log(result["_body"])
if (result["_body"] == "true") {
return true;
} else {
this._router.navigate(['/login']);
return false;
}
});
}
}
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.