-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Upgrading from rc.8 to rc.9 - JWT tokens not being stored by NbAuthService? #528
Comments
Hey @Dikymon, thanks for reporting. Could you provide a complete configuration of the auth module? Do you use a custom auth form or provided? And where you are trying to access the |
First off - thank you for a great library. Here is he auth configuration I am using
I am using a custom form, in the sense that I copied the auth components and made minor layout and wording changes. I updated those to use 'strategy' instead of 'provider' with reference to rc.9 component source - but most changes were just re-naming/typing variables. After succesful login, the user is redirected to a page with a Guard
Subscribing to authService.getToken()
yields
when sign-in is successful. In rc.8 it returned
|
@Dikymon in your
It looks to me, that the |
Here is the output, seems okay?
|
Right, this part is okay. And If you check the Application -> Localstorage tab in the chrome dev tools, could you post here what is stored there under then
|
key 'app_auth_token' seems to store it correctly:
|
Okay, now please open
|
It prints tokenPack
then throws an exception on the call to .getClassByName.
Which explains the use of the fallback class. |
That's great, we found the cause. What would be there if you print |
this.tokenClasses:
|
This is strange. It should be an array as it is provided by the NbAuthModule. Is |
Yes! That was it. Does that conflict with in some way? Thank you so much for your help, I hope it was not a complete waste of your time. |
Starting with rc.9 there is no need to provide a token (or tokens) anymore, just mention it in the strategy configuration No problem, glad we resolved it. I will leave the issue opened as supressing all of the errors in the token parceler class looks like a not very good idea as it hides such issues. |
Issue type
I'm submitting a ... (check one with "x")
Issue description
Current behavior:
After upgrading from rc.8 to rc.9 and refactoring to use the new Auth strategy, the JWT token emitted from NbAuthService.getToken() is empty (type NbAuthSimpleToken) after a succesful sign-in. I have verified that the token is correctly returned from the 'token.getter' method. What am i missing?
Expected behavior:
Token is emitted on AuthService.getToken() as in rc.8.
Related code:
Angular, Nebular
The text was updated successfully, but these errors were encountered: