Hello,
After reading through the docs I'm not sure how to clear my auth token when a user presses logout. In my case there is no need to hit an endpoint when a user logs out...simply redirect to login page and clear the auth token.
Thank you
Premature ask. Copied source files and will modify my settings there.
Is this possible without copying the source files?
I don't believe so but it made sense for me to copy the auth files as I did some extra customizations.
BUUTTT
by looking at their source code in token.service.ts you can see that the token is stored in local storage with a key 'auth_app_token'.
Should you want you can clear the token yourself when a user logs out in your app localStorage.removeItem('auth_app_token');
@jarredszabadi, @nsankaranarayanan you can just set the logout endpoint to empty string and it won't hit the endpoint and simply clear the token:
providers: {
email: {
...
config: {
logout: {
endpoint: '',
},
},
},
},
mmmmmm so much better. thanks
I'm trying to use logout method in both NbEmailPassAuthProvider and my custom provider.
Maybe I am missing something, but NbAuthService aways skips code inside switchMap()

I get the Observable form NbEmailPassAuthProvider (var test). Then the pipe and switchMap are skipped and I go right to the return test2.
So token is not being deleted and I am not redirected.
Any help would be appreciated
@ynotLeft
Maybe you won't reach the end point?
Try adding this to core.module.ts

Hi guys,
you can inject the NbTokenService and clear the data with this.nbTokenService.clear(); like this:
constructor(private sidebarService: NbSidebarService
private nbTokenService:NbTokenService) {
}
logout(){
this.nbTokenService.clear()
}
export class NgxLoginComponent extends NbLoginComponent implements OnInit {
ngOnInit() {
this.token.clear();
}
get token(): NbTokenService {
return InjectorHelper.injector.get(NbTokenService);
}
}
The logoutmethod returns an observable, so you need to subscribeto it to call it.
Most helpful comment
Hi guys,
you can inject the NbTokenService and clear the data with this.nbTokenService.clear(); like this:
constructor(private sidebarService: NbSidebarService
private nbTokenService:NbTokenService) {
}
logout(){
this.nbTokenService.clear()
}