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';
import { message } from 'antd';
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';
......@@ -73,7 +74,27 @@ export default {
{
let Data = null;
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;
case 38:
......
......@@ -36,7 +36,7 @@ export interface LoginModelType {
changeLoginStatus: Reducer<StateType>;
saveToken: Reducer<StateType>;
resetPwd: Reducer<StateType>;
setResultLogin: Reducer<StateType>
setResultLogin: Reducer<StateType>;
};
}
......@@ -50,7 +50,7 @@ const Model: LoginModelType = {
password: '',
result: false,
resultLogin: false,
userStatus: 0, // 0:首次登陆 1:修改密码
userStatus: 0, // 0:首次登陆 1:修改密码
},
reducers: {
......@@ -74,8 +74,8 @@ const Model: LoginModelType = {
setResultLogin(state, { resultLogin }) {
return {
...state,
resultLogin
}
resultLogin,
};
},
},
......@@ -98,16 +98,16 @@ const Model: LoginModelType = {
payload: response,
});
if (payload.remenber) {
const remenberUserName = getCookie("remenberUserName");
const remenberPwd = getCookie("remenberPwd");
const remenberUserName = getCookie('remenberUserName');
const remenberPwd = getCookie('remenberPwd');
if (!remenberUserName || !remenberPwd) {
// 存储密码
setCookie("remenberUserName", payload.values.userName, 7)
setCookie("remenberPwd", payload.values.password, 7)
setCookie('remenberUserName', payload.values.userName, 7);
setCookie('remenberPwd', payload.values.password, 7);
}
} else {
setCookie("remenberUserName", "", -1)
setCookie("remenberPwd", "", -1)
setCookie('remenberUserName', '', -1);
setCookie('remenberPwd', '', -1);
}
const userMessage = yield call(AccountCheckLogin, payload.values); // 请求时间网络
......@@ -150,21 +150,20 @@ const Model: LoginModelType = {
// 只跳到首页
history.replace('/');
} else {
message.error("Wrong account or password!");
message.error('Wrong account or password!');
yield put({
type: "setResultLogin",
type: 'setResultLogin',
resultLogin: true,
})
});
}
},
*logout({ }, { call, put }) {
*logout({}, { call, put }) {
const { redirect } = getPageQuery();
// Note: There may be security issues, please note
// const response = yield call(AccountOut, payload);
if (window.location.pathname !== '/user/login' && !redirect) {
// 清用户信息
// 清用户信息
localStorage.removeItem('userInfo');
localStorage.removeItem('permission');
localStorage.removeItem('CommunityList');
......@@ -209,10 +208,10 @@ const Model: LoginModelType = {
*setResult({ payload }, { put }) {
yield put({
type: "setResultLogin",
type: 'setResultLogin',
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