Mercurial > gemma
view client/src/stores/user.js @ 129:ee5a3dd8e972
Forgot to check if a db connection is already close when closing idle db connections.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Thu, 28 Jun 2018 16:45:01 +0200 |
parents | 88d0d60924cf |
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;