1- import { createAction } from 'redux-actions' ;
1+ import { createAction } from 'redux-actions' ;
22import * as types from '../constants/ActionTypes' ;
33import * as userService from '../services/userService' ;
44import * as tokenService from '../services/token' ;
55import * as storageService from '../services/storage' ;
66
77
8- export const checkToken = createAction ( types . CHECK_TOKEN , async ( token ) => {
8+ export const checkToken = createAction ( types . CHECK_TOKEN , async ( token ) => {
99 const userLoginInfo = await userService . req . checkToken ( token ) ;
1010 const user = await userService . req
1111 . getUserInfo ( userLoginInfo . loginname )
@@ -24,7 +24,7 @@ export const checkToken = createAction(types.CHECK_TOKEN, async (token)=> {
2424} ) ;
2525
2626
27- export const getUserFromStorage = createAction ( types . GET_USER_FROM_STORAGE , async ( ) => {
27+ export const getUserFromStorage = createAction ( types . GET_USER_FROM_STORAGE , async ( ) => {
2828 return await userService . storage . getUser ( )
2929 . then ( user => {
3030 tokenService . setToken ( user . secret . token ) ;
@@ -37,7 +37,7 @@ export const getUserFromStorage = createAction(types.GET_USER_FROM_STORAGE, asyn
3737} ) ;
3838
3939
40- export const updateClientUserInfo = createAction ( types . UPDATE_CLIENT_USER_INFO , async ( user ) => {
40+ export const updateClientUserInfo = createAction ( types . UPDATE_CLIENT_USER_INFO , async ( user ) => {
4141 return await userService . req . getUserInfo ( user . secret . loginname )
4242 . then ( userInfo => {
4343 if ( userInfo ) {
@@ -52,7 +52,7 @@ export const updateClientUserInfo = createAction(types.UPDATE_CLIENT_USER_INFO,
5252} ) ;
5353
5454
55- export const getUserInfo = createAction ( types . GET_USER_INFO , async ( loginName ) => {
55+ export const getUserInfo = createAction ( types . GET_USER_INFO , async ( loginName ) => {
5656 return await userService . req . getUserInfo ( loginName )
5757 . then ( userInfo => {
5858 if ( userInfo ) {
@@ -67,4 +67,9 @@ export const getUserInfo = createAction(types.GET_USER_INFO, async (loginName)=>
6767} ) ;
6868
6969
70- export const logout = createAction ( types . LOGOUT , userService . storage . clearUser ) ;
70+ export const logout = function ( ) {
71+ userService . storage . clearUser ( ) ;
72+ return {
73+ type : types . LOGOUT
74+ }
75+ } ;
0 commit comments