Skip to content

Commit

Permalink
Recupeção do token de login
Browse files Browse the repository at this point in the history
  • Loading branch information
quaresmateo authored and lubien committed May 18, 2019
1 parent f91d7db commit 7c20d78
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = {
/*
** Plugins to load before mounting the App
*/
plugins: [],
plugins: ['~/plugins/axios.js'],

/*
** Nuxt.js modules
Expand Down
3 changes: 3 additions & 0 deletions plugins/axios.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function({ $axios, store }) {
$axios.setToken(store.state.auth.token, 'Bearer')
}
2 changes: 1 addition & 1 deletion store/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const actions = {
return this.$axios
.$post('/api/auth', { username, password })
.then(({ token, user }) => {
this.$axios.setToken(token)
this.$axios.setToken(token, 'Bearer')
persist('token', token)
persist('user', user)
commit('setToken', token)
Expand Down

0 comments on commit 7c20d78

Please sign in to comment.