view src/stores/user.js @ 3:1597506a2241 vue-cli

merge with vue-cli
author Thomas Junk <thomas.junk@intevation.de>
date Wed, 13 Jun 2018 10:57:57 +0200
parents
children 7c1bde663c8e
line wrap: on
line source

const User = {
  namespaced: true,
  state: {
    authenticated: false,
    authStatus: "error"
  },
  getters: {
    authenticated: state => {
      return state.authenticated;
    },
    authStatus: state => {
      return state.authStatus;
    }
  },
  mutations: {
    auth_success: state => {
      state.authenticated = true;
    }
  },
  actions: {
    auth({ commit }, user) {
      const { username, password } = user;
      if (username === "admin" && password === "secret") {
        commit("auth_success");
      }
    }
  }
};

export default User;