Authored by 于良

修改密码成功后登出重新登录 review by yewanwan

... ... @@ -3,6 +3,7 @@
import React from 'react';
import ReactNative from 'react-native';
import Button from 'apsl-react-native-button';
import LoadingIndicator from './indicator/LoadingIndicator';
const {
Component,
... ... @@ -83,6 +84,10 @@ export default class ModifyPassword extends Component {
>
确定
</Button>
<LoadingIndicator
isVisible={this.props.isFetching}
/>
</View>
);
}
... ...
... ... @@ -21,7 +21,9 @@ export default keyMirror({
PWD_MODIFY_OLD:null,
PWD_MODIFY_NEW:null,
PWD_MODIFY_REPEAT:null,
PWD_MODIFY_SUBMIT:null,
PWD_MODIFY_REQUEST:null,
PWD_MODIFY_SUCCESS:null,
PWD_MODIFY_FAILURE:null,
MESSAGE_DETAIL:null,
REQUEST_MSG_LIST: null,
... ... @@ -44,10 +46,6 @@ export default keyMirror({
SET_SESSION_TOKEN: null,
RESET_PASSWORD_REQUEST: null,
RESET_PASSWORD_SUCCESS: null,
RESET_PASSWORD_FAILURE: null,
HOME_OVERVIEW_REQUEST: null,
HOME_OVERVIEW_SUCCESS: null,
HOME_OVERVIEW_FAILURE: null,
... ...
... ... @@ -78,7 +78,7 @@ export default class ModifyPasswordContainer extends Component {
}
componentWillUnmount() {
}
onModifyOldPwd(text:string){
... ... @@ -114,6 +114,7 @@ export default class ModifyPasswordContainer extends Component {
onModifyNewPwd={this.onModifyNewPwd}
onModifyRepeatPwd={this.onModifyRepeatPwd}
onModifySubmitPress={this.onModifySubmitPress}
isFetching={this.props.user.isFetching}
/>
);
... ...
... ... @@ -25,7 +25,9 @@ const {
PWD_MODIFY_OLD,
PWD_MODIFY_NEW,
PWD_MODIFY_REPEAT,
PWD_MODIFY_SUBMIT,
PWD_MODIFY_REQUEST,
PWD_MODIFY_SUCCESS,
PWD_MODIFY_FAILURE,
LOGIN_REQUEST,
LOGIN_SUCCESS,
... ... @@ -37,11 +39,6 @@ const {
SET_SESSION_TOKEN,
RESET_PASSWORD_REQUEST,
RESET_PASSWORD_SUCCESS,
RESET_PASSWORD_FAILURE,
PHONE_CALL,
ABOUT_US,
USER_ITEMS_PRESSED,
... ... @@ -193,29 +190,41 @@ export function pwdModifyRepeat(pwd) {
};
}
export function modifySubmitRequest() {
return {
type: PWD_MODIFY_REQUEST
};
}
export function modifySubmitSuccess() {
Actions.pop();
return {
type: PWD_MODIFY_SUCCESS
};
}
export function modifySubmitFailure() {
return {
type: PWD_MODIFY_FAILURE
};
}
export function pwdModifySubmit(pid, oldPwd, newPwd,newPwdConfirm) {
let userService = new UserService();
return dispatch => {
dispatch(loginRequest());
dispatch(modifySubmitRequest());
return userService.modifyPassword(pid, oldPwd, newPwd,newPwdConfirm)
.then(function (json) {
Alert.alert(
'修改成功',
'',
[
{text: 'OK', onPress: () => Actions.pop()},
]
);
dispatch(modifySubmitDone());
dispatch(modifySubmitSuccess());
dispatch(logout());
})
.catch((error) => {
Alert.alert(
error.message,
'',
[{text: 'OK'}]
);
dispatch(loginFailure(error));
error.message,
'',
[{text: 'OK'}]
);
dispatch(modifySubmitFailure(error));
});
};
}
... ... @@ -230,7 +239,7 @@ export function login(account, password) {
return userService.storeUserInfo(json)
.then(() => {
dispatch(loginSuccess(json));
dispatch(setupHomeDefaultBrand(json.shops[0].shopsId, json.shops[0].shopName))
dispatch(setupHomeDefaultShop(json.shops[0].shopsId, json.shops[0].shopName));
Actions.Drawer();
});
})
... ... @@ -246,14 +255,6 @@ export function login(account, password) {
}
export function modifySubmitDone() {
Actions.pop();
return {
type: PWD_MODIFY_SUBMIT
};
}
export function getStoredUserInfo() {
return dispatch => {
... ...
... ... @@ -28,7 +28,9 @@ const {
PWD_MODIFY_OLD,
PWD_MODIFY_NEW,
PWD_MODIFY_REPEAT,
PWD_MODIFY_SUBMIT,
PWD_MODIFY_REQUEST,
PWD_MODIFY_SUCCESS,
PWD_MODIFY_FAILURE,
LOGIN_REQUEST,
LOGIN_SUCCESS,
... ... @@ -40,10 +42,6 @@ const {
SET_SESSION_TOKEN,
RESET_PASSWORD_REQUEST,
RESET_PASSWORD_SUCCESS,
RESET_PASSWORD_FAILURE,
CHECK_UPDATE_SUCCESS,
CHECK_UPDATE_FAILURE,
... ... @@ -90,8 +88,10 @@ export default function userReducer(state = initialState, action) {
let nextState = state.setIn(['password', 'repeat'], action.payload);
return nextState;
}
case PWD_MODIFY_SUBMIT:{
let nextState = state.setIn(['password', 'old'], '')
case PWD_MODIFY_SUCCESS:{
let nextState = state.set('isFetching', false)
.set('error', null)
.setIn(['password', 'old'], '')
.setIn(['password', 'new'], '')
.setIn(['password', 'repeat'], '');
return nextState;
... ... @@ -106,7 +106,7 @@ export default function userReducer(state = initialState, action) {
}
case LOGIN_REQUEST:
case RESET_PASSWORD_REQUEST: {
case PWD_MODIFY_REQUEST: {
let nextState = state.set('isFetching', true)
.set('error', null);
return nextState;
... ... @@ -125,12 +125,12 @@ export default function userReducer(state = initialState, action) {
}
case LOGOUT_SUCCESS:
case RESET_PASSWORD_SUCCESS:
return state.set('isFetching', false);
return state.set('isFetching', false)
.set('error', null);
case LOGOUT_FAILURE:
case LOGIN_FAILURE:
case RESET_PASSWORD_FAILURE:
case PWD_MODIFY_FAILURE:
return state.set('isFetching', false)
.set('error', action.payload);
... ...