-
Notifications
You must be signed in to change notification settings - Fork 485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tokenNotExpired and AuthConfig #11
Comments
Hey! Are you trying to specify another token name for @CanActivate(() => tokenNotExpired('my_token_name')) Let me know if that's what you're looking for :) |
Hi, Thanks for the fast reply! That's what I am trying to achieve but I was wondering if it was possible to do it without specifying the name in the function. Just to keep it DRY. I tried to create an AuthVerificationService that would look like the following : import {Injectable} from 'angular2/core';
import {AuthConfig, tokenNotExpired} from 'angular2-jwt';
@Injectable()
export class AuthVerificationService {
constructor(private authConfig:AuthConfig) { }
tokenVerified():boolean {
var token = this.authConfig.tokenGetter();
return tokenNotExpired(null, token);
}
} and have it injected in my "private" components, but I don't know how to do the following part : import {Component} from 'angular2/core';
import {CanActivate} from 'angular2/router';
import {AuthVerificationService} from '../services/auth-verification.service';
@Component( ... )
@CanActivate(() => AuthVerificationService.tokenVerified()) // Error, "static" method not good...
export class DashboardComponent { } I might as well just keep the default name and getter... If you have any idea to do it though I'll be happy to read about it =D Thanks again. Cheers! |
This is actually probably something that |
Need PR? |
Until this is integrated it would be great if it was mentioned in the docs. I spent a couple hours trying to figure out why |
@RicardoRFaria feel free to submit a PR if you like :) @h0st1le good call--I'll add that, thanks. |
any progress on this? |
Hello, any updates on this? |
Hello, help anyone! tokenNotExpired return false |
@denishp83 Here also the same! @chenkie After successful login, tokenNotExpired always returns false. So it doesn't redirect the secured page. Any Idea pls? NOTE: I manually passed stored localstorage token name to tokenNotExpired method. It resolves the problem but I don't think this is the right way! |
@kksrini89 have you double checked that the correct token is used by |
@chenkie Yes I did. But it showed me tokenNotExpired is not defined even though I have given reference using |
Ok if it's not defined then that's likely another problem. Probably best to open a separate issue for it. |
sure. Let me create a new ticket for this! thanks @chenkie |
Hi,
I am using angular2-jwt for my first angular 2 app.
I find it quite easy to use, which is nice :)
I have a simple question, and it's about the tokenNotExpired function, as well as the AuthConfig.
Is it possible for the tokenNotExpired function to get the tokenName from the AuthConfig (as well as the getter function?) ?
Injected authconfig into my component did not make it available in the @CanActivate annotation.
I might as well just rename my token to the default id_token, but I think it would be nice to get the same config everywhere.
I have no idea if this is a simple task or not, as I am just starting with Angular 2 (without any Angular 1 background).
Anyway, thanks for this little plugin,
Cheers!
The text was updated successfully, but these errors were encountered: