-
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
Access token is not stored after login #55
Comments
Hello @aloxiao, we would need much more details on this, are you using ngx-admin? Which provider are you using? Could you provide a reproducible example? |
Dear @nnixaa , I use ngx-admin, i clone ngx-admin 5 day ago when new update Auth (link https://github.com/akveo/nebular/blob/master/docs/articles/auth-concepts-install.md) . Thanks you for your reply. |
Same issue here. My token is in the header of the response from the server - do I need to change the token config from this: token: { to something else? I've tried debugging it through but can't work out what I need to change to specifically tell it where to find the token. |
I'm now returning the token as json in the content of the response, i.e. 'token' : 'hsgfhgdhjfgdshfgdfgds', it |
You need to have your response structured as such { "data": { "token": "token_value" } }. You can also try to change the token.key from 'data.token' to just 'token' in your auth config. -Mustafa |
Dear @janabimustafa, Where is config? Thanks! |
Mine is in const NB_CORE_PROVIDERS = [
...DataModule.forRoot().providers,
...NbAuthModule.forRoot({
providers: {
email: {
service: NbEmailPassAuthProvider,
config: {
baseEndpoint: '/api',
token: {
key: 'token',
},
... |
@janabimustafa you beat me to it. I had located this yesterday. Basically if you follow the new auth guide you just need to update the token key in the provider that you created. So this should be a file that you created in your instance and added to the module. |
I ended up hacking the authenticate method in email-pass-auth provider to get it out of the body, so it doesn't need to use getConfigValue() for the token. Will have a look at refactoring it properly at some point! Thanks for the help. |
I also have problem with this. Token comes from response.body.token, and cant access it |
Hi,
I make it docs/articles/auth-guard.md.
At app-routing.module.ts
{
path: 'pages',
canActivate: [AuthGuard], //add line
loadChildren: 'app/pages/pages.module#PagesModule' },
}
...
Result cosole.log(result); //line 53 in login.component.js
NbAuthResult {success: true, response: HttpResponse, redirect: "/", errors: Array(1), messages: Array(1), …}
However, page not nagivator to "pages/dashboard". If i hidden line canActivate then I can access dashboard but deafault load login.
Where is error?
Pleases help me!
(My english is not so good).
The text was updated successfully, but these errors were encountered: