3
|
1 const User = {
|
|
2 namespaced: true,
|
|
3 state: {
|
|
4 authenticated: false,
|
|
5 authStatus: "error"
|
|
6 },
|
|
7 getters: {
|
|
8 authenticated: state => {
|
|
9 return state.authenticated;
|
|
10 },
|
|
11 authStatus: state => {
|
|
12 return state.authStatus;
|
|
13 }
|
|
14 },
|
|
15 mutations: {
|
|
16 auth_success: state => {
|
|
17 state.authenticated = true;
|
|
18 }
|
|
19 },
|
|
20 actions: {
|
|
21 auth({ commit }, user) {
|
|
22 const { username, password } = user;
|
|
23 if (username === "admin" && password === "secret") {
|
|
24 commit("auth_success");
|
|
25 }
|
|
26 }
|
|
27 }
|
|
28 };
|
|
29
|
|
30 export default User;
|