Giter Site home page Giter Site logo

Clear token on logout about nebular HOT 10 CLOSED

akveo avatar akveo commented on May 5, 2024
Clear token on logout

from nebular.

Comments (10)

nnixaa avatar nnixaa commented on May 5, 2024 9

@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: '',
          },
        },
      },
    },

from nebular.

netchon avatar netchon commented on May 5, 2024 8

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()
}

from nebular.

dedpnd avatar dedpnd commented on May 5, 2024 4

@ynotLeft
Maybe you won't reach the end point?
Try adding this to core.module.ts

image

from nebular.

jarredszabadi avatar jarredszabadi commented on May 5, 2024

Premature ask. Copied source files and will modify my settings there.

from nebular.

nsankaranarayanan avatar nsankaranarayanan commented on May 5, 2024

Is this possible without copying the source files?

from nebular.

jarredszabadi avatar jarredszabadi commented on May 5, 2024

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');

from nebular.

jarredszabadi avatar jarredszabadi commented on May 5, 2024

mmmmmm so much better. thanks

from nebular.

ynotLeft avatar ynotLeft commented on May 5, 2024

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()

screen shot 2018-03-06 at 3 48 16 pm

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

from nebular.

jasonvuriker avatar jasonvuriker commented on May 5, 2024
export class NgxLoginComponent extends NbLoginComponent implements OnInit {
  ngOnInit() {
    this.token.clear();
  }

  get token(): NbTokenService {
    return InjectorHelper.injector.get(NbTokenService);
  }
}

from nebular.

babgev avatar babgev commented on May 5, 2024

The logout method returns an observable, so you need to subscribe to it to call it.

from nebular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.