Last active
January 19, 2020 19:37
-
-
Save MrNaif2018/f36b3cc3ccd162749ee4b026e73d5a50 to your computer and use it in GitHub Desktop.
Authentification using @nuxtjs/auth(JWT with refresh tokens)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.$axios.post('/token', { | |
email: this.email, | |
password: this.password | |
}).then((resp) => { | |
this.$auth.setToken('local', 'Bearer ' + resp.data.access_token) | |
this.$auth.setRefreshToken('local', resp.data.refresh_token) | |
this.$axios.setHeader('Authorization', 'Bearer ' + resp.data.access_token) | |
this.$auth.ctx.app.$axios.setHeader('Authorization', 'Bearer ' + resp.data.access_token) | |
this.$axios.get('/users/me').then((resp) => { this.$auth.setUser(resp.data); this.$router.push('/') }) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment