feat: add reset phone by verification code

Signed-off-by: Kininaru <shiftregister233@outlook.com>

fixed client bug

Signed-off-by: Kininaru <shiftregister233@outlook.com>

feat: add i18n

Signed-off-by: Kininaru <shiftregister233@outlook.com>

add Casbin License

Signed-off-by: Kininaru <shiftregister233@outlook.com>

removed port from remoteaddr

Signed-off-by: Kininaru <shiftregister233@outlook.com>
This commit is contained in:
Kininaru
2021-05-12 22:09:41 +08:00
parent 400e335e68
commit 827930a020
10 changed files with 191 additions and 15 deletions

View File

@ -47,10 +47,10 @@ export const ResetModal = (props) => {
setConfirmLoading(true);
UserBackend.resetEmailOrPhone(dest, destType, code).then(res => {
if (res.status === "ok") {
Setting.showMessage("success", i18next.t(destType + " reset"));
Setting.showMessage("success", i18next.t("user:" + destType + " reset"));
window.location.reload();
} else {
Setting.showMessage("error", i18next.t(res.msg));
Setting.showMessage("error", i18next.t("user:" + res.msg));
setConfirmLoading(false);
}
})
@ -84,6 +84,10 @@ export const ResetModal = (props) => {
})
}
let placeHolder = "";
if (destType === "email") placeHolder = i18next.t("user:Input your email");
else if (destType === "phone") placeHolder = i18next.t("user:Phone prefix is needed");
return (
<Row>
<Button style={{marginTop: '22px'}} type="default" onClick={showModal}>
@ -101,7 +105,7 @@ export const ResetModal = (props) => {
>
<Col style={{margin: "0px auto 40px auto", width: 1000, height: 300}}>
<Row style={{width: "100%", marginBottom: "20px"}}>
<Input addonBefore={i18next.t("user:New " + destType)} id="dest"
<Input addonBefore={i18next.t("user:New " + destType)} id="dest" placeholder={placeHolder}
addonAfter={<button style={{width: "90px", border: "none", backgroundColor: "#fff"}} onClick={sendCode}>{" " + sendButtonText + " "}</button>}
/>

View File

@ -285,14 +285,8 @@ class UserEditPage extends React.Component {
{i18next.t("general:Phone")}:
</Col>
<Col span={22} >
<Input addonBefore={
<Select virtual={false} style={{width: 70}} value={this.state.user.phonePrefix} onChange={(value => {this.updateUserField('phonePrefix', value);})}>
<Option value="1">+1</Option>
<Option value="86">+86</Option>
</Select>
} value={this.state.user.phone} onChange={e => {
this.updateUserField('phone', e.target.value);
}} />
<Input value={"+" + this.state.user.phonePrefix + this.state.user.phone} disabled/>
{ this.state.user.id === this.props.account.id ? (<ResetModal buttonText={i18next.t("user:Reset Phone")} destType={"phone"} coolDownTime={60}/>) : null}
</Col>
</Row>
<Row style={{marginTop: '20px'}} >

View File

@ -115,7 +115,26 @@
"Invalid new password": "Invalid new password",
"Password": "Password",
"Cancel": "Cancel",
"input password": "input password"
"input password": "input password",
"Reset Email": "Reset Email",
"Reset Phone": "Reset Phone",
"Send Code": "Send Code",
"Empty email": "Empty Email",
"Empty phone": "Empty Phone",
"Empty Code": "Empty Code",
"phone reset": "Phone Reset",
"email reset": "Email Reset",
"Code Sent": "Code Sent",
"Input your email": "Input your email",
"Phone prefix is needed": "Phone prefix is needed",
"New phone": "New Phone",
"New email": "New Email",
"Code You Received": "Code You Received",
"Enter your code": "Enter your code",
"You can only send one code in 60s.": "You can only send one code in 60s.",
"Code has not been sent yet!": "Code has not been sent yet!",
"You should verify your code in 5 min!": "You should verify your code in 5 min!",
"Wrong code!": "Wrong code!"
},
"application":
{

View File

@ -117,7 +117,26 @@
"Invalid new password": "非法的新密码。",
"Password": "密码",
"Cancel": "取消",
"input password": "输入密码"
"input password": "输入密码",
"Reset Email": "重设邮箱",
"Reset Phone": "重设电话",
"Send Code": "发送验证码",
"Empty email": "邮箱为空",
"Empty phone": "电话为空",
"Empty Code": "验证码为空",
"phone reset": "电话已设置",
"email reset": "邮箱已设置",
"Code Sent": "验证码已发送",
"Input your email": "请输入邮箱",
"Phone prefix is needed": "记得输入地区前缀(+86",
"New phone": "新的电话号",
"New email": "新的邮箱",
"Code You Received": "你收到的验证码",
"Enter your code": "输入你的验证码",
"You can only send one code in 60s.": "每分钟你只能发送一次验证码",
"Code has not been sent yet!": "你还没有发送验证码",
"You should verify your code in 5 min!": "验证码已超时。你应该在 5 分钟内完成验证。",
"Wrong code!": "验证码错误!"
},
"application":
{