diff --git a/src/App.js b/src/App.js index b412c0e5..42f8bef5 100644 --- a/src/App.js +++ b/src/App.js @@ -159,7 +159,7 @@ class App extends Component { const login = cookie.load("login"); let path = this.props.history.location.pathname; - if(login && (path === "/login" || path === "/register" ||path === "/resetPassword" )){ + if(login && (path === "/login" || path === "/register" || path === "/resetPassword" || path.indexOf("/bindlogin") >-1 )){ this.props.history.push(`/${login}`); } // 添加路由监听,决定组织还是个人 diff --git a/src/AppConfig.js b/src/AppConfig.js index 74288bea..e87c10bd 100644 --- a/src/AppConfig.js +++ b/src/AppConfig.js @@ -26,7 +26,7 @@ if (isDev) { } debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' : window.location.search.indexOf('debug=s') !== -1 ? 'student' : - window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || 'admin' + window.location.search.indexOf('debug=a') !== -1 ? 'admin' : parsed.debug || '' } window._debugType = debugType; export function initAxiosInterceptors(props) { @@ -70,7 +70,7 @@ export function initAxiosInterceptors(props) { if (response.data.status === -1) { if (window.location.pathname.startsWith('/tasks/')) { props.showSnackbar(response.data.message || '服务器异常,请联系管理员。') - } else if(window.location.pathname.startsWith('/login') || window.location.pathname.startsWith('/register') || window.location.pathname.startsWith('/resetPassword')) { + } else if(window.location.pathname.startsWith('/login') || window.location.pathname.startsWith('/register') || window.location.pathname.startsWith('/resetPassword') || window.location.pathname.indexOf("/bindlogin/")>-1) { return response; } else { notification.open({ diff --git a/src/forge/Account/bind.jsx b/src/forge/Account/bind.jsx index aa009cb2..983c781b 100644 --- a/src/forge/Account/bind.jsx +++ b/src/forge/Account/bind.jsx @@ -14,7 +14,6 @@ function Bind(props){ const { getFieldDecorator , getFieldsValue } = form; const [ bindFlag , setBindFlag] = useState(true); const type = props.match.params.type; - // 绑定登录 function bindloginFunc(){ const {username, password } = getFieldsValue(); @@ -23,10 +22,12 @@ function Bind(props){ axios.post(url,{ username,password,type }).then(result=>{ - if(result){ + if(result && result.data.status === 0){ cookie.save("supplyphone",true); cookie.save("login",result.data.login); window.location.href = "/"+result.data.login; + }else{ + props.showNotification(result.data.message); } }) } diff --git a/src/forge/Account/unbind.jsx b/src/forge/Account/unbind.jsx index 5bab356c..84232eaa 100644 --- a/src/forge/Account/unbind.jsx +++ b/src/forge/Account/unbind.jsx @@ -49,29 +49,50 @@ function Bind(props){ setCaptchaFlag(true); callback(`请输入正确的手机号或邮箱地址`); }else{ - setCaptchaFlag(false); - if(captcha && password && confirm_password && (password === confirm_password) && register_username){ - setBindFlag(false); - } + axios.get(`/accounts/valid_email_and_phone.json`, { + params: { + login: value, + type: 1 + } + }).then(response => { + if(response){ + if (response.data.status === -2) { + callback(response.data.message); + } else { + setCaptchaFlag(false); + if(captcha && password && confirm_password && (password === confirm_password) && register_username){ + setBindFlag(false); + } + } + callback(); + } + }) } - callback(); }else{ setBindFlag(true); callback(); } } function psdConfirm(r,v,c){ - if(v){ + if(!v){ + setBindFlag(true); + c('请输入登录密码'); + }else if(/(?!.*\s)(?!^[\u4e00-\u9fa5]+$)^.{8,16}$/.test(v)){ const { username , captcha , confirm_password , register_username } = getFieldsValue(); if(register_username && (phonereg.test(username) || emailreg.test(username)) && captcha && confirm_password && (v=== confirm_password) ){ setBindFlag(false); }else{ setBindFlag(true); } - c(); + c() }else{ - c(); - setBindFlag(true); + if(v.length<8 || v.length>16){ + setBindFlag(true); + c('密码长度为8-16个字符'); + }else{ + setBindFlag(true); + c('密码不能使用空格'); + } } } function captchaConfirm(r,v,c){ @@ -89,6 +110,28 @@ function Bind(props){ } } function repsdConfirm(r,v,c){ + if(!v){ + setBindFlag(true); + c("请重复输入登录密码"); + }else if(/(?!.*\s)(?!^[\u4e00-\u9fa5]+$)^.{8,16}$/.test(v)){ + const { username , password , register_username , captcha} = getFieldsValue(); + if(v !== password){ + c("两次输入的密码不一样"); + }else if((phonereg.test(username) || emailreg.test(username)) && password && register_username && captcha){ + setBindFlag(false); + }else{ + setBindFlag(true); + } + c(); + }else{ + if(v.length<8 || v.length>16){ + setBindFlag(true); + c('密码长度为8-16个字符'); + }else{ + setBindFlag(true); + c('密码不能使用空格'); + } + } if(v){ const { username , password , register_username , captcha} = getFieldsValue(); if(v !== password){ @@ -214,7 +257,8 @@ function Bind(props){ validator: (rule, value, callback) => { accountConfirm(rule, value, callback) } } ], - validateTrigger:"onInput", + validateTrigger:"onBlur", + validateFirst: true, })(} size="large" placeholder="请输入手机号或邮箱地址"/>)}