This commit is contained in:
caishi 2022-12-30 11:59:33 +08:00
parent c0bbe817d8
commit acb87c7e09
6 changed files with 70 additions and 23 deletions

View File

@ -159,7 +159,7 @@ class App extends Component {
const login = cookie.load("login"); const login = cookie.load("login");
let path = this.props.history.location.pathname; 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}`); this.props.history.push(`/${login}`);
} }
// 添加路由监听,决定组织还是个人 // 添加路由监听,决定组织还是个人

View File

@ -26,7 +26,7 @@ if (isDev) {
} }
debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' : debugType = window.location.search.indexOf('debug=t') !== -1 ? 'teacher' :
window.location.search.indexOf('debug=s') !== -1 ? 'student' : 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; window._debugType = debugType;
export function initAxiosInterceptors(props) { export function initAxiosInterceptors(props) {
@ -70,7 +70,7 @@ export function initAxiosInterceptors(props) {
if (response.data.status === -1) { if (response.data.status === -1) {
if (window.location.pathname.startsWith('/tasks/')) { if (window.location.pathname.startsWith('/tasks/')) {
props.showSnackbar(response.data.message || '服务器异常,请联系管理员。') 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; return response;
} else { } else {
notification.open({ notification.open({

View File

@ -14,7 +14,6 @@ function Bind(props){
const { getFieldDecorator , getFieldsValue } = form; const { getFieldDecorator , getFieldsValue } = form;
const [ bindFlag , setBindFlag] = useState(true); const [ bindFlag , setBindFlag] = useState(true);
const type = props.match.params.type; const type = props.match.params.type;
// //
function bindloginFunc(){ function bindloginFunc(){
const {username, password } = getFieldsValue(); const {username, password } = getFieldsValue();
@ -23,10 +22,12 @@ function Bind(props){
axios.post(url,{ axios.post(url,{
username,password,type username,password,type
}).then(result=>{ }).then(result=>{
if(result){ if(result && result.data.status === 0){
cookie.save("supplyphone",true); cookie.save("supplyphone",true);
cookie.save("login",result.data.login); cookie.save("login",result.data.login);
window.location.href = "/"+result.data.login; window.location.href = "/"+result.data.login;
}else{
props.showNotification(result.data.message);
} }
}) })
} }

View File

@ -49,29 +49,50 @@ function Bind(props){
setCaptchaFlag(true); setCaptchaFlag(true);
callback(`请输入正确的手机号或邮箱地址`); callback(`请输入正确的手机号或邮箱地址`);
}else{ }else{
setCaptchaFlag(false); axios.get(`/accounts/valid_email_and_phone.json`, {
if(captcha && password && confirm_password && (password === confirm_password) && register_username){ params: {
setBindFlag(false); 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{ }else{
setBindFlag(true); setBindFlag(true);
callback(); callback();
} }
} }
function psdConfirm(r,v,c){ 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(); const { username , captcha , confirm_password , register_username } = getFieldsValue();
if(register_username && (phonereg.test(username) || emailreg.test(username)) && captcha && confirm_password && (v=== confirm_password) ){ if(register_username && (phonereg.test(username) || emailreg.test(username)) && captcha && confirm_password && (v=== confirm_password) ){
setBindFlag(false); setBindFlag(false);
}else{ }else{
setBindFlag(true); setBindFlag(true);
} }
c(); c()
}else{ }else{
c(); if(v.length<8 || v.length>16){
setBindFlag(true); setBindFlag(true);
c('密码长度为8-16个字符');
}else{
setBindFlag(true);
c('密码不能使用空格');
}
} }
} }
function captchaConfirm(r,v,c){ function captchaConfirm(r,v,c){
@ -89,6 +110,28 @@ function Bind(props){
} }
} }
function repsdConfirm(r,v,c){ 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){ if(v){
const { username , password , register_username , captcha} = getFieldsValue(); const { username , password , register_username , captcha} = getFieldsValue();
if(v !== password){ if(v !== password){
@ -214,7 +257,8 @@ function Bind(props){
validator: (rule, value, callback) => { accountConfirm(rule, value, callback) } validator: (rule, value, callback) => { accountConfirm(rule, value, callback) }
} }
], ],
validateTrigger:"onInput", validateTrigger:"onBlur",
validateFirst: true,
})(<Input className="account" addonBefore={<img src={phone} alt="" width="13px" />} size="large" placeholder="请输入手机号或邮箱地址"/>)} })(<Input className="account" addonBefore={<img src={phone} alt="" width="13px" />} size="large" placeholder="请输入手机号或邮箱地址"/>)}
</Form.Item> </Form.Item>
<Form.Item> <Form.Item>
@ -261,7 +305,7 @@ function Bind(props){
validator: (rule, value, callback) => { repsdConfirm(rule, value, callback) } validator: (rule, value, callback) => { repsdConfirm(rule, value, callback) }
} }
], ],
validateTrigger:"onBlur", validateTrigger:"onInput",
})( })(
<Input.Password autoComplete="new-password" addonBefore={<img src={lock} alt="" width="13px" />} className="psd" size="large" placeholder="请确认登录密码" />, <Input.Password autoComplete="new-password" addonBefore={<img src={lock} alt="" width="13px" />} className="psd" size="large" placeholder="请确认登录密码" />,
)} )}

View File

@ -12,12 +12,14 @@ function Personal(props){
const [ showedit , setShowEdit ] = useState(false); const [ showedit , setShowEdit ] = useState(false);
const [ description ,setDescription ] = useState(""); const [ description ,setDescription ] = useState("");
const [ copyDescription ,setCopyDescription ] = useState(""); const [ copyDescription ,setCopyDescription ] = useState("");
console.log(user);
useEffect(()=>{ useEffect(()=>{
setDescription(user.super_description); if(current_user && current_user.super_description){
setCopyDescription(user.super_description); setDescription(current_user.super_description);
setShowEdit(true); setCopyDescription(current_user.super_description);
},[user && user.super_description]) setShowEdit(true);
}
},[current_user && current_user.super_description])
function onContentChange(value){ function onContentChange(value){
setDescription(value); setDescription(value);

View File

@ -5,8 +5,8 @@ import { notification , Tooltip } from 'antd';
import axios from 'axios'; import axios from 'axios';
import educoderLogo from './educoder.png'; import educoderLogo from './educoder.png';
import qqlogo from './qq.png'; import qqlogo from './qq@2x.png';
import WeChatlogo from './WeChat.png'; import WeChatlogo from './WeChat@2x.png';
import giteelogo from './gitee.png'; import giteelogo from './gitee.png';
import githublogo from './github.png'; import githublogo from './github.png';
import cookie from 'react-cookies'; import cookie from 'react-cookies';