dirmich avatar

Nuxt.js Authenticate with JWT

dirmich

Published: 25 Aug 2018 › Updated: 25 Aug 2018Nuxt.js Authenticate with JWT

Nuxt.js Authenticate with JWT

[Login]

  1. login process with passport
    --> req.user is generated automatically by passport
  2. create route for '/auth/token' for get jwt token with req.user
  3. create nuxtServerInit for fetching token and set token to store.state
  4. check authenticated by middleware

[Logout]

  1. create route for '/auth/logout' includes followings:
    router.get('/auth/logout', (req,res)=>{
    req.logout()
    req.redirect(>>front main url or sign-in url<<)
    ...
    })
  2. delete token and other user-info from state.store
  3. window.location.replace( BACKEND+'/auth/logout')

Leave Nuxt.js Authenticate with JWT to:

Written by

programmer in freedom

Read more #nuxt posts


Best Posts From dirmich

We have not curated any of dirmich's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From dirmich