-
Notifications
You must be signed in to change notification settings - Fork 189
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
canActivate always blocks the routes (even after signIn) #113
Comments
If something like this happens its usually an timing issue. The CanActivate method checks if AuthData is set.
In your second example your console.log() methods are outside the subscribe method, so they get run before .signIn() finishes.
You should check where you redirect and if it triggers before the backend has a chance to answer your signIn call. |
Well, so how can I solve this timing issue? In fact, this 2nd example is just to check why the canActivate isn't working... I also tested this inside the subscribe method and it gives the same response. Thanks for your quick response. |
@neroniaky, do you have any solution for this? |
I have the same problem, is there any news? |
@rafaelss95 @chaskas are you using SystemJS? |
No, I'm using webpack. |
@neroniaky Yes I am. |
@neroniaky, can you share the code of the demo site (https://angular2-token.herokuapp.com)? I didn't found here in this repo. |
@rafaelss95 README, paragraph 3. 😉 |
Hi! Is someone still having this issue? I'm working on a RoR BackEnd and it is generating the token. Angular (or A2T) is also setting it in the local storage as I'm capable of seeing it in the Application tab on DevTools. Thing is that |
Hi everyone, i'm getting this same issue, has anyone found any solution to this already ? Thnks. |
For me, the solution was to expose the headers as suggested here, due to i'm running the backend and front as separated apps. |
@rafaelss95 use .map instead of using subscribe and return it, something like this: return this.tokenService.signIn({ |
In case anyone is struggling with that like me I noticed that when calling the sign_in method the headers were not being returned and that's why I couldn't authenticate the user. what solved for me was to expose the headers at the back-end.
|
Hello, I'm trying to use the
canActivate
as below:Actually it works to not activate the routes, but even after call
signIn()
method, the routes can't be accessed. It always show me blanks page. So as a test I decided to check what's the response after callsignIn()
method and it always return false. I also tried to use thevalidateToken()
to check something and it always return the following:Example:
How can I fix it? Or is it a known issue?
The text was updated successfully, but these errors were encountered: