Please read TokenNotExpired (https://github.com/auth0/angular2-jwt). It is
a function provided by angular2-jwt.
I updated source code:
*Login.ts*
>
> login(event, username, password) {
>
> if (username === 'test' && password === 'test') {
> var token =
> 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VybmFtZSI6InRlc3QiLCJpZCI6MiwiaWF0IjoxNDY1Mzc4MzA5LCJleHAiOjE0NjUzOTYzMDl9.lpf_R4O9rP3Vc9JYK_6aYrC_xaO2zvCBJwpB7k6vOQM';
> localStorage.setItem('jwt', token);
> this.router.parent.navigateByUrl('/home');
> }
> }
>
*Home.ts* constructor(public router: Router, public http: Http, public
authHttp: AuthHttp) {
this.jwt = localStorage.getItem('jwt');
* let test = tokenNotExpired(); console.log(test); alert(test);*
}
TokenNotExpired says null.
On Tuesday, June 7, 2016 at 8:54:39 PM UTC+5, Sander Elias wrote:
>
> Hi Adnan
>
> <nav *ngIf='validTokenId()'>
>
> the function validTokenId should be in your controller, and do what the
> name suggests.
> Is that enough for you?
>
> Regards
> Sander
>
--
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.