Mercurial > gemma
view client/src/stores/user.js @ 13:88d0d60924cf
Move vuejs app into subdir `client`
Using a subdirectory for the web application keeps more structure
in the repo.
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Wed, 20 Jun 2018 17:02:06 +0200 |
parents | src/stores/user.js@7c1bde663c8e |
children | 992e17912405 |
line wrap: on
line source
import { HTTP } from "../lib/http"; const User = { namespaced: true, state: { authenticated: false }, getters: { authenticated: state => { return state.authenticated; } }, mutations: { auth_success: (state, token) => { state.authenticated = true; sessionStorage.setItem("token", token); }, auth_failure: state => { state.authenticated = false; sessionStorage.removeItem("token"); } }, actions: { login({ commit }, user) { return new Promise((resolve, reject) => { HTTP.post("/token", user) .then(response => { let token = response.data; commit("auth_success", token); resolve(response); }) .catch(error => { commit("auth_failure"); reject(error); }); }); } } }; export default User;