diff 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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/stores/user.js	Wed Jun 13 10:57:57 2018 +0200
@@ -0,0 +1,30 @@
+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;