|
@@ -36,41 +36,41 @@ const actions = {
|
|
|
login({ commit }, userInfo) {
|
|
|
console.log(userInfo);
|
|
|
const { phone, code } = userInfo;
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
return new Promise((resolve, reject) => {
|
|
|
- login({
|
|
|
- data: {
|
|
|
- account: phone,
|
|
|
- signInType: 'MOBILE_NUMBER_SMS',
|
|
|
- smsCode: code
|
|
|
- }
|
|
|
- })
|
|
|
- .then(response => {
|
|
|
- const { data } = response;
|
|
|
-
|
|
|
- if (data.token) {
|
|
|
- commit('SET_TOKEN', data.token);
|
|
|
- setToken(data.token);
|
|
|
- resolve();
|
|
|
- } else {
|
|
|
- reject(data.message);
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- reject(error);
|
|
|
- });
|
|
|
+ const data = {
|
|
|
+ token: 'admin-token'
|
|
|
+ };
|
|
|
+ commit('SET_TOKEN', data.token);
|
|
|
+ setToken(data.token);
|
|
|
+ resolve();
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
|
|
|
|
|
|
- getInfo({ commit, state }) {
|
|
|
+ getInfo({ commit, state, dispatch }) {
|
|
|
|
|
|
|
|
|
|
|
@@ -92,11 +92,10 @@ const actions = {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
getInfo(state.token)
|
|
|
.then(async response => {
|
|
|
- console.log(response);
|
|
|
- const { data } = response;
|
|
|
+ const { data, success } = response;
|
|
|
|
|
|
- if (!success && !data) {
|
|
|
- dispatch('user/logout');
|
|
|
+ if (!success) {
|
|
|
+ dispatch('logout');
|
|
|
return reject('Verification failed, please Login again.');
|
|
|
}
|
|
|
|
|
@@ -112,8 +111,7 @@ const actions = {
|
|
|
resolve(data);
|
|
|
})
|
|
|
.catch(error => {
|
|
|
- console.error('-dada');
|
|
|
- dispatch('user/logout');
|
|
|
+ dispatch('logout');
|
|
|
reject(error);
|
|
|
});
|
|
|
});
|
|
@@ -121,19 +119,19 @@ const actions = {
|
|
|
|
|
|
|
|
|
logout({ commit, state }) {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- logout(state.token)
|
|
|
- .then(() => {
|
|
|
- removeToken();
|
|
|
- resetRouter();
|
|
|
- commit('RESET_STATE');
|
|
|
- commit('SET_ROLES', []);
|
|
|
- resolve();
|
|
|
- })
|
|
|
- .catch(error => {
|
|
|
- reject(error);
|
|
|
- });
|
|
|
- });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ removeToken();
|
|
|
+ resetRouter();
|
|
|
+ commit('RESET_STATE');
|
|
|
+ commit('SET_ROLES', []);
|
|
|
+ resolve();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
},
|
|
|
|
|
|
|