Commit 3dbcbfe8 authored by 周宏民's avatar 周宏民

pref: 登录验证码改为后端较验

parent 5e688ed5
......@@ -15,6 +15,7 @@ instanceRequest.transformRequestURL = function(url) {
'/PandaOMS/OMS/WebSite/GetConfig',
'/PandaOMS/OMS/CheckFreeLogin',
'/PandaCore/GCK/BussinessAuth/HDAuthLogin',
'/PandaCore/Identity/GetAliyunSMSVerificationCode',
];
if (excludeURL.includes(url)) {
return url.replace(/PandaCore\/GateWay\//, '');
......
......@@ -18,7 +18,9 @@ export const API = {
GET_CITY: process.env.NODE_ENV !== 'production' ? '/cityjson?ie=utf-8' : 'https://pv.sohu.com',
GET_ALL_GROUPS_INFO_FORUSER: '/PandaCore/GCK/CloudPlat/GetAllGroupsInfoForUser',
GET_WEATHER: '/CityInterface/rest/services/CountyProduct.svc/GetWeather',
SEND_MESSAGE_CODE: 'CityInterface/rest/services/portal.svc/SendMessVerificationCode',
SEND_MESSAGE_CODE: 'CityInterface/rest/services/portal.svc/SendMessVerificationCode', // 获取验证码 前端校验
GetAliyunSMSVerificationCodeHasWay: '/PandaCore/Identity/GetAliyunSMSVerificationCode', // 获取验证码 走网关
GetAliyunSMSVerificationCode: 'PandaCore/GCK/BussinessAuth/GetAliyunSMSVerificationCode', // 获取验证码 不走网关
CHANGE_PASSWORD: 'cityinterface/rest/services.svc/changepassword',
CHANGE_PASSWORD_SAFE: '/PandaOMS/OMS/UserCenter/UpdateUserPassword',
HD_AUTH_LOGIN: '/PandaCore/GCK/BussinessAuth/HDAuthLogin',
......@@ -177,6 +179,16 @@ const services = {
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
GetAliyunSMSVerificationCodeHasWay: {
url: API.GetAliyunSMSVerificationCodeHasWay,
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
GetAliyunSMSVerificationCode: {
url: API.GetAliyunSMSVerificationCode,
method: constants.REQUEST_METHOD_GET,
type: constants.REQUEST_HTTP,
},
updateAvatar: {
url: API.UPDATE_AVATAR,
method: constants.REQUEST_METHOD_GET,
......
......@@ -139,21 +139,41 @@ const LoginItem = props => {
const onGetCaptcha = useCallback(mobile => {
// eslint-disable-next-line no-undef
appService
.sendMessVerificationCode({
phoneNumber: mobile,
ignoreSite: true,
cacheBust: true,
})
.then(res => {
if (res) {
setExt(res.ext);
setTiming(true);
}
})
.catch(error => {
message.error(intl.formatMessage({ id: 'pages.login.phoneLogin.errorCodeMessage' }));
});
if (window.globalConfig?.hasGateWay) {
// 开户网关
appService
.GetAliyunSMSVerificationCodeHasWay({
phoneNumber: mobile,
ignoreSite: true,
cacheBust: true,
})
.then(res => {
if (res) {
setExt(res.ext);
setTiming(true);
}
})
.catch(error => {
message.error(intl.formatMessage({ id: 'pages.login.phoneLogin.errorCodeMessage' }));
});
} else {
// 不开网关
appService
.GetAliyunSMSVerificationCode({
phoneNumber: mobile,
ignoreSite: true,
cacheBust: true,
})
.then(res => {
if (res) {
setExt(res.ext);
setTiming(true);
}
})
.catch(error => {
message.error(intl.formatMessage({ id: 'pages.login.phoneLogin.errorCodeMessage' }));
});
}
}, []);
useEffect(() => {
......@@ -183,18 +203,17 @@ const LoginItem = props => {
if (type === 'Captcha') {
const inputProps = omit(otherProps, ['onGetCaptcha', 'countDown']);
const equalsValidate = (rule, value) => {
if (value === ext || value === '8888') {
return Promise.resolve();
}
// eslint-disable-next-line prefer-promise-reject-errors
return Promise.reject(intl.formatMessage({ id: 'pages.login.phoneLogin.errorMessage' }));
};
// const equalsValidate = (rule, value) => {
// if (value === ext || value === '8888') {
// return Promise.resolve();
// }
// return Promise.reject(intl.formatMessage({ id: 'pages.login.phoneLogin.errorMessage' }));
// };
// eslint-disable-next-line no-shadow
const rulesArr = [...rules];
rulesArr.push({
validator: equalsValidate,
});
// rulesArr.push({
// validator: equalsValidate,
// });
delete options.rules;
return (
......
......@@ -1375,7 +1375,7 @@ class Login {
}
}
login(usr, pwd, userPhone, isRememberPWD, mode = SERVICE_APP_LOGIN_MODE.password) {
login(usr, pwd, userPhone, isRememberPWD, mode = SERVICE_APP_LOGIN_MODE.password, captcha) {
this.globalConfig = getGlobalConfig();
const self = this;
if (window.globalConfig && window.globalConfig.hasGateWay) {
......@@ -1391,6 +1391,7 @@ class Login {
: '',
type: mode,
generateType: params.getParams('generateType') || '',
vcode: captcha
})
.then(res => {
if (res.code === 0) {
......@@ -1442,6 +1443,8 @@ class Login {
ignoreSite: true,
loginName: usr,
generateType: params.getParams('generateType') || '',
vcode: captcha,
})
.then(response => {
if (response?.msg === '密码过期') {
......@@ -1633,7 +1636,7 @@ class Login {
}
phoneLoginFormHandler(userPhone, captcha) {
this.login('', '', userPhone, '', SERVICE_APP_LOGIN_MODE.phone);
this.login('', '', userPhone, '', SERVICE_APP_LOGIN_MODE.phone, captcha);
}
slideVerify(ref, onSuccess, onFail, onRefresh) {
......
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