|
@@ -53,9 +53,7 @@ export default {
|
53
|
53
|
authStatus: state => state.status,
|
54
|
54
|
},
|
55
|
55
|
actions: {
|
56
|
|
- init({
|
57
|
|
- commit,
|
58
|
|
- }) {
|
|
56
|
+ init({ commit }) {
|
59
|
57
|
if (!log.isLoggedIn() && log.tokenExpired) {
|
60
|
58
|
log.clearValues();
|
61
|
59
|
} else log.updateTokenExpiry();
|
|
@@ -66,37 +64,31 @@ export default {
|
66
|
64
|
agency: log.getJSONObject('agency'),
|
67
|
65
|
});
|
68
|
66
|
},
|
69
|
|
- login({
|
70
|
|
- commit,
|
71
|
|
- state,
|
72
|
|
- }) {
|
73
|
|
- return new Promise((reject) => {
|
74
|
|
- commit('auth_request');
|
75
|
|
- const user = {
|
|
67
|
+ login({ commit, state }) {
|
|
68
|
+ axios({
|
|
69
|
+ url: '/api/register/authenticate',
|
|
70
|
+ data: {
|
76
|
71
|
username: state.username,
|
77
|
72
|
password: state.password,
|
78
|
|
- };
|
79
|
|
- axios({
|
80
|
|
- url: '/api/register/authenticate',
|
81
|
|
- data: user,
|
82
|
|
- method: 'POST',
|
|
73
|
+ },
|
|
74
|
+ method: 'POST',
|
|
75
|
+ })
|
|
76
|
+ .then((resp) => {
|
|
77
|
+ log.clearValues();
|
|
78
|
+ log.setValues(resp.data);
|
|
79
|
+ console.log(resp.data);
|
|
80
|
+
|
|
81
|
+ commit('auth_success', resp.data);
|
83
|
82
|
})
|
84
|
|
- .then((resp) => {
|
85
|
|
- log.clearValues();
|
86
|
|
- log.setValues(resp.data);
|
87
|
|
- commit('auth_success', resp.data);
|
88
|
|
- })
|
89
|
|
- .catch((err) => {
|
90
|
|
- commit('auth_error');
|
91
|
|
- log.clearValues();
|
92
|
|
- reject(err);
|
93
|
|
- commit('auth_error', err.data);
|
94
|
|
- });
|
95
|
|
- });
|
|
83
|
+ .catch((err) => {
|
|
84
|
+ commit('auth_error');
|
|
85
|
+ log.clearValues();
|
|
86
|
+ // reject(err);
|
|
87
|
+ commit('auth_error', err.data);
|
|
88
|
+ });
|
|
89
|
+ /* }); */
|
96
|
90
|
},
|
97
|
|
- logout({
|
98
|
|
- commit,
|
99
|
|
- }) {
|
|
91
|
+ logout({ commit }) {
|
100
|
92
|
return new Promise(() => {
|
101
|
93
|
commit('logout');
|
102
|
94
|
log.clearValues();
|