diff --git a/src/forge/users/Material/Password.jsx b/src/forge/users/Material/Password.jsx index aae00b3fb..9aaeb2027 100644 --- a/src/forge/users/Material/Password.jsx +++ b/src/forge/users/Material/Password.jsx @@ -1,6 +1,7 @@ -import React , { forwardRef, useState } from 'react'; +import React , { forwardRef, Fragment, useState } from 'react'; import { Form , Input , Button, message } from 'antd'; import { AlignCenter } from '../../Component/layout'; +import Modals from '../../Component/PublicModal/Index'; import Axios from 'axios'; import img1 from '../../Images/personalInfo3.png'; import { setmiyah } from '../../../common/Component'; @@ -8,7 +9,7 @@ import { useEffect } from 'react'; export default Form.create()( forwardRef((props)=>{ - const { getFieldDecorator, validateFields, resetFields } = props && props.form; + const { getFieldDecorator, validateFields, resetFields, getFieldsValue } = props && props.form; const { current_user, type, resetUserInfo} = props; const [ NewPass , setNewPass ] = useState(undefined); @@ -16,7 +17,8 @@ export default Form.create()( const [ countDown, setCountDown] = useState(undefined); const [ emailValue, setEmailValue] = useState(undefined); const [ passMap, setPassMap] = useState({password: undefined, email: undefined, code: undefined}); - const [ updatePsdMap, setUpdatePsdMap] = useState({oldPassword: undefined, password: undefined, password1: undefined}) + const [ updatePsdMap, setUpdatePsdMap] = useState({oldPassword: undefined, password: undefined, password1: undefined}); + const [ visible, setVisible] = useState(false); useEffect(()=>{ setPassMap({password: undefined, email: undefined, code: undefined}); @@ -26,25 +28,11 @@ export default Form.create()( function submit() { validateFields((error,values)=>{ if(!error){ - submitFunc(values); + setVisible(true); } }) } - function submitFunc(values) { - const url = `/accounts/change_password.json`; - Axios.post(url,{ - login:current_user && current_user.login, - ...values - }).then(result=>{ - if(result && result.data){ - resetFields(); - setUpdatePsdMap({oldPassword: undefined, password: undefined, password1: undefined}); - message.success('密码重置成功!'); - } - }).catch(error=>{}) - } - // 判断两次输入的密码是否一致 var reg = /(?!.*\s)(?!^[\u4e00-\u9fa5]+$)^.{8,16}$/; function checkIdentifier(rule, value, callback , inputValue){ @@ -89,7 +77,9 @@ export default Form.create()( email: emailValue, smscode: setmiyah(emailValue) }}).then(res=>{ - console.log('res', res); + if(res && !res.data.status){ + message.success('发送成功') + } }) // 获取验证码 startCountDown(); @@ -110,196 +100,260 @@ export default Form.create()( // 校验用户密码是否正确 function checkPsd(rule, value, callback){ - current_user && Axios.post(`/v1/${current_user.login}/check_password.json`,{ - password: value - }).then(res=>{ - const map = type === '0' ? passMap : updatePsdMap; - if(res && !res.data.status){ - if(type === '0'){ - map.password = value; - setPassMap(map); + const map = type === '0' ? passMap : updatePsdMap; + if(value){ + current_user && Axios.post(`/v1/${current_user.login}/check_password.json`,{ + password: value + }).then(res=>{ + if(res && !res.data.status){ + if(type === '0'){ + map.password = value; + setPassMap(map); + }else{ + map.oldPassword = value; + setUpdatePsdMap(map); + } + callback(); }else{ - map.oldPassword = value; - setUpdatePsdMap(map); + if(type === '0'){ + map.password = undefined; + setPassMap(map); + }else{ + map.oldPassword = undefined; + setUpdatePsdMap(map); + } + callback(res.data.message); } - callback(); + }) + }else{ + if(type === '0'){ + map.password = undefined; + setPassMap(map); }else{ - if(type === '0'){ - map.password = undefined; - setPassMap(map); - }else{ - map.oldPassword = undefined; - setUpdatePsdMap(map); - } - callback(res.data.message); + map.oldPassword = undefined; + setUpdatePsdMap(map); } - }) + callback(); + } } // 校验用户邮箱是否正确 function checkEmail(rule, value, callback){ - current_user && Axios.post(`/v1/${current_user.login}/check_email.json`,{ - email: value - }).then(res=>{ - const map = passMap; - if(res && !res.data.status){ - map.email = value; - setPassMap(map); - setEmailValue(value); - callback(); - }else{ - map.email = undefined; - setPassMap(map); - callback(res.data.message); - } - }) + const map = passMap; + if(value){ + current_user && Axios.post(`/v1/${current_user.login}/check_email.json`,{ + email: value + }).then(res=>{ + if(res && !res.data.status){ + map.email = value; + setPassMap(map); + setEmailValue(value); + callback(); + }else{ + setEmailValue(undefined); + map.email = undefined; + setPassMap(map); + callback(res.data.message); + } + }) + }else{ + setEmailValue(undefined); + map.email = undefined; + setPassMap(map); + callback(); + } } // 校验用户填写验证码是否正确 function checkCode(rule, value, callback){ - current_user && value && value.length > 4 && Axios.post(`/v1/${current_user.login}/check_email_verify_code.json`,{ - code_type: 10, - email: emailValue, - code: value - }).then(res=>{ - const map = passMap; - if(res && !res.data.status){ - map.code = value; - setPassMap(map); - callback(); - }else{ - map.code = undefined; - setPassMap(map); - callback(res.data.message); + const map = passMap; + if(value){ + current_user && value && value.length > 4 && Axios.post(`/v1/${current_user.login}/check_email_verify_code.json`,{ + code_type: 10, + email: emailValue, + code: value + }).then(res=>{ + if(res && !res.data.status){ + map.code = value; + setPassMap(map); + callback(); + }else{ + map.code = undefined; + setPassMap(map); + callback(res.data.message); + } + }) + }else{ + map.code = undefined; + setPassMap(map); + callback(); + } + } + + // 提交更改邮箱表单 + function confirmUpdateEmail(e){ + validateFields((error,values)=>{ + if(!error){ + setVisible(true); } }) } - // 提交更改邮箱表单 - function updateEmail(e){ - console.log('提交更改邮箱表单', e); - validateFields((error,values)=>{ - if(!error){ - const {code, email, password1} = values; - if(code && email && password1){ - current_user && Axios.patch(`/v1/${current_user.login}/update_email.json`,{ - code, email, password: password1 - }).then(res=>{ - if(res && !res.data.status){ - setPassMap({password: undefined, email: undefined, code: undefined}); - resetFields(); - resetUserInfo(); - message.success('更新成功'); - }else{ - message.error(res.data.message || '更新失败'); - } - }) - } + function updateEmailOrPsd(){ + if(type === '0'){ + const {code, email, password1} = getFieldsValue(); + if(code && email && password1){ + current_user && Axios.patch(`/v1/${current_user.login}/update_email.json`,{ + code, email, password: password1 + }).then(res=>{ + if(res && !res.data.status){ + setPassMap({password: undefined, email: undefined, code: undefined}); + resetFields(); + resetUserInfo(); + setVisible(false); + message.success('更新成功'); + }else{ + setVisible(false); + message.error(res.data.message || '更新失败'); + } + }) + } + }else{ + const values = getFieldsValue(); + const url = `/accounts/change_password.json`; + Axios.post(url,{ + login:current_user && current_user.login, + ...values + }).then(result=>{ + if(result && result.data){ + resetFields(); + setUpdatePsdMap({oldPassword: undefined, password: undefined, password1: undefined}); + setVisible(false); + setNewPass(undefined); + setNewPassRepeat(undefined); + message.success('密码重置成功!'); + } + }).catch(error=>{}) } - }) } -console.log('1111', updatePsdMap.password1); // type: 0邮箱管理 1密码管理 2账号注销 return( - type === '0' ?
-
更改邮箱后,您在GitLink 的登陆账号,接受通知的邮箱,git config 邮件地址将同步变更。请谨慎更改!
-
现邮箱地址{current_user && current_user.email}
-
更改邮箱
-
- - {getFieldDecorator("password1",{ - rules:[ - {required:true,message:"请输入登录密码"}, - {validator:(rule, value, callback)=>checkPsd(rule, value, callback)} - ], - validateFirst: true, - validateTrigger:"onBlur", - })( - - )} - - - {getFieldDecorator("email",{ - rules:[ - {required:true,message:"请输入新邮箱地址"}, - {type: 'email',message: '请输入正确的邮箱格式'}, - {validator:(rule, value, callback)=>checkEmail(rule, value, callback)} - ], - validateFirst: true, - validateTrigger:"onBlur", - })( - - )} - -
- - {getFieldDecorator("code",{ + + {type === '0' ?
+
更改邮箱后,您在GitLink 的登录账号、接收通知的邮件地址、git config 邮件地址将同步变更。请谨慎更改!
+
现邮箱地址{current_user && current_user.email}
+
更改邮箱
+ + + {getFieldDecorator("password1",{ rules:[ - {required:true,message:"请输入邮箱验证码"}, - {validator:(rule, value, callback)=>checkCode(rule, value, callback)} - ] + {required:true,message:"请输入登录密码"}, + {validator:(rule, value, callback)=>checkPsd(rule, value, callback)} + ], + validateTrigger:"onBlur", })( - + )} - {countDown ? : } -
+ + {getFieldDecorator("email",{ + rules:[ + {required:true,message:"请输入新邮箱地址"}, + {type: 'email',message: '请输入正确的邮箱格式'}, + {validator:(rule, value, callback)=>checkEmail(rule, value, callback)} + ], + validateTrigger:"onBlur", + })( + + )} + +
+ + {getFieldDecorator("code",{ + rules:[ + {required:true,message:"请输入邮箱验证码"}, + {validator:(rule, value, callback)=>checkCode(rule, value, callback)} + ], + validateTrigger:"onBlur", + })( + + )} + + {countDown ? : } +
+ + + + + +
: type === '1' ?
+ + {getFieldDecorator("old_password",{ + rules:[ + {required:true,message:"请输入旧密码"}, + {validator:(rule, value, callback)=>checkPsd(rule, value, callback)} + ], + validateTrigger:"onBlur", + })( + + )} + + + {getFieldDecorator("password",{ + rules:[ + {required:true,message:"请输入新密码"}, + {validator:(rule, value, callback)=>checkNewPass(rule, value, callback, NewPassRepeat)} + ], + validateFirst: true, + validateTrigger:"onBlur", + })( + {setNewPass(e.target.value)}}/> + )} + + + {getFieldDecorator("new_password_repeat",{ + rules:[ + {required:true,message:"请重新输入新密码"}, + {validator:(rule, value, callback)=>checkIdentifier(rule, value, callback, NewPass)} + ], + validateFirst: true, + validateTrigger:"onBlur", + })( + {setNewPassRepeat(e.target.value)}}/> + )} + - + -
-
: type === '1' ?
- - {getFieldDecorator("old_password",{ - rules:[ - {required:true,message:"请输入旧密码"}, - {validator:(rule, value, callback)=>checkPsd(rule, value, callback)} - ], - validateFirst: true, - validateTrigger:"onBlur", - })( - - )} - - - {getFieldDecorator("password",{ - rules:[ - {required:true,message:"请输入新密码"}, - {validator:(rule, value, callback)=>checkNewPass(rule, value, callback, NewPassRepeat)} - ], - validateFirst: true, - validateTrigger:"onBlur", - })( - {setNewPass(e.target.value)}}/> - )} - - - {getFieldDecorator("new_password_repeat",{ - rules:[ - {required:true,message:"请重新输入新密码"}, - {validator:(rule, value, callback)=>checkIdentifier(rule, value, callback, NewPass)} - ], - validateFirst: true, - validateTrigger:"onBlur", - })( - {setNewPassRepeat(e.target.value)}}/> - )} - - - - - -
:
-
请您谨慎操作,注销后帐号内所有数据都会被清空,且无法恢复帐号!
-
- GitLink目前提供邮件渠道帐号注销服务。如需注销帐号,请通过发送邮件注销申请邮件到 gitlink@ccf.org.cn
- 相关注意事项如下:
- 必须使用要注销的 GitLink 帐号所绑定的邮箱地址发送邮件。 - 发送注销申请邮件之前确认帐号下无创建/加入组织,帐号名下无仓库信息。 - 邮件标题: 注销 GitLink 帐号,邮件正文请注明要注销帐号的邮箱和昵称。 - 发送邮件后,我们会积极处理,请耐心等候我们的邮件回复。 -
-
+ :
+
请您谨慎操作,注销后帐号内所有数据都会被清空,且无法恢复帐号!
+
+ GitLink目前提供邮件渠道帐号注销服务。如需注销帐号,请通过发送邮件注销申请邮件到 gitlink@ccf.org.cn
+ 相关注意事项如下:
+ 必须使用要注销的 GitLink 帐号所绑定的邮箱地址发送邮件。 + 发送注销申请邮件之前确认帐号下无创建/加入组织,帐号名下无仓库信息。 + 邮件标题: 注销 GitLink 帐号,邮件正文请注明要注销帐号的邮箱和昵称。 + 发送邮件后,我们会积极处理,请耐心等候我们的邮件回复。 +
+
} + {setVisible(false)}} + title={type==='0'? '更改邮箱' : '更改密码'} + btn={ +
+ + +
+ } + > +
+ + 确认更改{type === '0' ? '邮箱' : '密码'}? +

{type === '0' ? '更改邮箱后,您在GitLink的登录账号、接收通知的邮件地址、git config 邮件地址将同步变更。请再次确认。' : '更改密码后,您在GitLink的登录密码将同步变更。请再次确认。'}

+
+
+ )}) ) \ No newline at end of file diff --git a/src/home/Img/2-3-2.png b/src/home/Img/2-3-2.png index 8c9858d72..d1bbc6735 100755 Binary files a/src/home/Img/2-3-2.png and b/src/home/Img/2-3-2.png differ diff --git a/src/home/Img/2-3-3.png b/src/home/Img/2-3-3.png index b603513eb..b11b0c803 100644 Binary files a/src/home/Img/2-3-3.png and b/src/home/Img/2-3-3.png differ diff --git a/src/home/Img/2-3-4.png b/src/home/Img/2-3-4.png index d8152a975..ac636dace 100644 Binary files a/src/home/Img/2-3-4.png and b/src/home/Img/2-3-4.png differ