|
|
@ -1,6 +1,6 @@ |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
import { ApiTable, AxyRequest } from '$utils' |
|
|
|
import { ApiTable, AxyRequest, EmisRequest } from '$utils' |
|
|
|
|
|
|
|
export const INIT_AUTH = 'INIT_AUTH'; |
|
|
|
export function initAuth (userData) { |
|
|
@ -32,17 +32,17 @@ export function login (username, password) { |
|
|
|
return Promise.resolve(); |
|
|
|
} |
|
|
|
|
|
|
|
return dispatch({ |
|
|
|
type: LOGIN_SUCCESS, |
|
|
|
payload: { |
|
|
|
user: { |
|
|
|
authorized: true, |
|
|
|
namePresent: 'TEST' |
|
|
|
} |
|
|
|
}, |
|
|
|
}); |
|
|
|
// return dispatch({
|
|
|
|
// type: LOGIN_SUCCESS,
|
|
|
|
// payload: {
|
|
|
|
// user: {
|
|
|
|
// authorized: true,
|
|
|
|
// namePresent: 'TEST'
|
|
|
|
// }
|
|
|
|
// },
|
|
|
|
// });
|
|
|
|
|
|
|
|
return AxyRequest.post(ApiTable.login, { username, password, domain: 'anxinyun' }) |
|
|
|
return EmisRequest.post(ApiTable.login, { username, password, code: 'POMS' }) |
|
|
|
.then(user => { |
|
|
|
sessionStorage.setItem('pomsUser', JSON.stringify(user)); |
|
|
|
return dispatch({ |
|
|
@ -65,8 +65,9 @@ export const LOGOUT = 'LOGOUT'; |
|
|
|
export function logout () { |
|
|
|
const user = JSON.parse(sessionStorage.getItem('pomsUser')) |
|
|
|
user && user.token ? |
|
|
|
AxyRequest.post(ApiTable.logout, { |
|
|
|
token: user.token |
|
|
|
EmisRequest.post(ApiTable.logout, { |
|
|
|
token: user.token, |
|
|
|
code: 'POMS' |
|
|
|
}) : null; |
|
|
|
sessionStorage.removeItem('pomsUser'); |
|
|
|
return { |
|
|
|