Commit da71641e authored by cellee's avatar cellee

修改密码重新登录

Signed-off-by: cellee's avatarcellee <893264950@qq.com>
parent 1c6ae294
...@@ -2,7 +2,8 @@ import * as service from '../../services/tos'; ...@@ -2,7 +2,8 @@ import * as service from '../../services/tos';
import { message } from 'antd'; import { message } from 'antd';
import { Link, useIntl, connect, Dispatch, history } from 'umi'; import { Link, useIntl, connect, Dispatch, history } from 'umi';
import { routerRedux } from 'dva/router'; import { stringify } from 'querystring';
import { setCookie } from '@/utils/method';
import { printf } from '@/utils/log'; import { printf } from '@/utils/log';
...@@ -73,7 +74,27 @@ export default { ...@@ -73,7 +74,27 @@ export default {
{ {
let Data = null; let Data = null;
yield put({ type: 'returnPage', Data }); yield put({ type: 'returnPage', Data });
history.push('/AccountManagement/account');
if (resp.data.isEditPsw && resp.data.isEditPsw == 1) {
// 这是修改了密码 需要重新登录
// 清除用户信息
localStorage.removeItem('userInfo');
localStorage.removeItem('permission');
localStorage.removeItem('CommunityList');
setCookie('token', '');
setCookie('id', '');
setCookie('name', '');
setCookie('phone', '');
history.replace({
pathname: '/user/login',
search: stringify({
redirect: window.location.href,
}),
});
message.success('Password modified successfully, login again!');
} else {
history.push('/AccountManagement/account');
}
} }
break; break;
case 38: case 38:
......
...@@ -36,7 +36,7 @@ export interface LoginModelType { ...@@ -36,7 +36,7 @@ export interface LoginModelType {
changeLoginStatus: Reducer<StateType>; changeLoginStatus: Reducer<StateType>;
saveToken: Reducer<StateType>; saveToken: Reducer<StateType>;
resetPwd: Reducer<StateType>; resetPwd: Reducer<StateType>;
setResultLogin: Reducer<StateType> setResultLogin: Reducer<StateType>;
}; };
} }
...@@ -50,7 +50,7 @@ const Model: LoginModelType = { ...@@ -50,7 +50,7 @@ const Model: LoginModelType = {
password: '', password: '',
result: false, result: false,
resultLogin: false, resultLogin: false,
userStatus: 0, // 0:首次登陆 1:修改密码 userStatus: 0, // 0:首次登陆 1:修改密码
}, },
reducers: { reducers: {
...@@ -74,8 +74,8 @@ const Model: LoginModelType = { ...@@ -74,8 +74,8 @@ const Model: LoginModelType = {
setResultLogin(state, { resultLogin }) { setResultLogin(state, { resultLogin }) {
return { return {
...state, ...state,
resultLogin resultLogin,
} };
}, },
}, },
...@@ -98,16 +98,16 @@ const Model: LoginModelType = { ...@@ -98,16 +98,16 @@ const Model: LoginModelType = {
payload: response, payload: response,
}); });
if (payload.remenber) { if (payload.remenber) {
const remenberUserName = getCookie("remenberUserName"); const remenberUserName = getCookie('remenberUserName');
const remenberPwd = getCookie("remenberPwd"); const remenberPwd = getCookie('remenberPwd');
if (!remenberUserName || !remenberPwd) { if (!remenberUserName || !remenberPwd) {
// 存储密码 // 存储密码
setCookie("remenberUserName", payload.values.userName, 7) setCookie('remenberUserName', payload.values.userName, 7);
setCookie("remenberPwd", payload.values.password, 7) setCookie('remenberPwd', payload.values.password, 7);
} }
} else { } else {
setCookie("remenberUserName", "", -1) setCookie('remenberUserName', '', -1);
setCookie("remenberPwd", "", -1) setCookie('remenberPwd', '', -1);
} }
const userMessage = yield call(AccountCheckLogin, payload.values); // 请求时间网络 const userMessage = yield call(AccountCheckLogin, payload.values); // 请求时间网络
...@@ -150,21 +150,20 @@ const Model: LoginModelType = { ...@@ -150,21 +150,20 @@ const Model: LoginModelType = {
// 只跳到首页 // 只跳到首页
history.replace('/'); history.replace('/');
} else { } else {
message.error("Wrong account or password!"); message.error('Wrong account or password!');
yield put({ yield put({
type: "setResultLogin", type: 'setResultLogin',
resultLogin: true, resultLogin: true,
}) });
} }
}, },
*logout({ }, { call, put }) { *logout({}, { call, put }) {
const { redirect } = getPageQuery(); const { redirect } = getPageQuery();
// Note: There may be security issues, please note // Note: There may be security issues, please note
// const response = yield call(AccountOut, payload); // const response = yield call(AccountOut, payload);
if (window.location.pathname !== '/user/login' && !redirect) { if (window.location.pathname !== '/user/login' && !redirect) {
// 清用户信息 // 清用户信息
localStorage.removeItem('userInfo'); localStorage.removeItem('userInfo');
localStorage.removeItem('permission'); localStorage.removeItem('permission');
localStorage.removeItem('CommunityList'); localStorage.removeItem('CommunityList');
...@@ -209,10 +208,10 @@ const Model: LoginModelType = { ...@@ -209,10 +208,10 @@ const Model: LoginModelType = {
*setResult({ payload }, { put }) { *setResult({ payload }, { put }) {
yield put({ yield put({
type: "setResultLogin", type: 'setResultLogin',
resultLogin: payload.resultLogin || false, resultLogin: payload.resultLogin || false,
}) });
} },
}, },
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment