Published: 25 Aug 2018 › Updated: 25 Aug 2018

Nuxt.js Authenticate with JWT
[Login]
- login process with passport
--> req.user is generated automatically by passport - create route for '/auth/token' for get jwt token with req.user
- create nuxtServerInit for fetching token and set token to store.state
- check authenticated by middleware
[Logout]
- create route for '/auth/logout' includes followings:
router.get('/auth/logout', (req,res)=>{
req.logout()
req.redirect(>>front main url or sign-in url<<)
...
}) - delete token and other user-info from state.store
- window.location.replace( BACKEND+'/auth/logout')
Leave Nuxt.js Authenticate with JWT to:
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.