diff --git a/lib/templates/auth.store.js b/lib/templates/auth.store.js index f62937b12..9c2b2d595 100644 --- a/lib/templates/auth.store.js +++ b/lib/templates/auth.store.js @@ -36,7 +36,7 @@ export default { actions: { <% if (options.token.enabled) { %> // Update token - updateToken ({ commit }, token) { + async updateToken ({ commit }, token) { // Update token in store's state commit('SET_TOKEN', token) @@ -82,7 +82,7 @@ export default { <% if (options.token.enabled) { %> // Fetch Token - fetchToken ({ dispatch }) { + async fetchToken ({ dispatch }) { let token <% if (options.token.localStorage) { %> @@ -102,15 +102,15 @@ export default { <% } %> if (token) { - dispatch('updateToken', token) + await dispatch('updateToken', token) } }, <% } %> // Reset - reset ({ dispatch, commit }) { + async reset ({ dispatch, commit }) { <% if (options.user.enabled) { %>commit('SET_USER', null)<% } %> - <% if (options.token.enabled) { %>dispatch('updateToken', null)<% } %> + <% if (options.token.enabled) { %>await dispatch('updateToken', null)<% } %> }, <% if (options.user.enabled) { %> @@ -122,7 +122,7 @@ export default { <% if (options.token.enabled) { %> // Fetch and update latest token - dispatch('fetchToken') + await dispatch('fetchToken') // Skip if there is no token set if (!state.token) { @@ -138,7 +138,7 @@ export default { console.error(e) <% if (options.user.resetOnFail) { %> // Reset store - dispatch('reset') + await dispatch('reset') <% } %> } }, @@ -150,7 +150,7 @@ export default { let data = await (this.$axios || this.app.$axios).$post(endpoint, fields) <% if (options.token.enabled) { %> - dispatch('updateToken', data['<%= options.token.name %>']) + await dispatch('updateToken', data['<%= options.token.name %>']) <% } %> // Fetch authenticated user @@ -170,7 +170,7 @@ export default { } // Reset store - dispatch('reset') + await dispatch('reset') } } }