-1

I've looking for a while for how I can implement the JWT interceptor and auth guard in the ngx-admin without any success. How can I do that?

I've tried following @WebVbn's tutorial in this thread, Add JWT automatically for every HTTP request #1375, but it didn't work and honestly I'm still kinda new to this whole angular and ngx-admin stuff

Greenonline
  • 1,330
  • 8
  • 23
  • 31
user10976183
  • 287
  • 1
  • 2
  • 13

1 Answers1

0

that's how to configure it in your front-end to support JWT.

Of course your back-end should support it, and you can configure your routes as you wish, this is just an example

  export const NB_CORE_PROVIDERS = [
  ...DataModule.forRoot().providers,
  ...NbAuthModule.forRoot({

    strategies: [

      NbPasswordAuthStrategy.setup({
        name: 'email',
        baseEndpoint:"http://localhost:8080/api/",
      requestPass:false,
      logout:{ 
        endpoint:'auth/logout',
        method:'post',
        requireValidToken:true
      },
      resetPass:{
        endpoint:"auth/reset",
        redirect:{
          success:"/",
          failure:"/auth/login"
        }
      },
      refreshToken:{
        endpoint:'auth/refresh',
        method:"post"
      },
        login: {
          endpoint: 'auth/login',
          method:"post",
          redirect:{
            success:"/pages"
          },
          requireValidToken:true
        },
        token: {
          class: NbAuthJWTToken,
          key:'token'
        }
      }),
    ],
Or Yaacov
  • 3,597
  • 5
  • 25
  • 49