mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 18:54:03 +08:00
feat: fix bug in signup and reset phone and email (#1396)
* fix: fix bug in signup and reset phone and email * delete useless addition
This commit is contained in:
parent
ef836acfe9
commit
eca2527bc0
@ -47,6 +47,7 @@ func (c *ApiController) SendVerificationCode() {
|
|||||||
checkKey := c.Ctx.Request.Form.Get("checkKey")
|
checkKey := c.Ctx.Request.Form.Get("checkKey")
|
||||||
checkUser := c.Ctx.Request.Form.Get("checkUser")
|
checkUser := c.Ctx.Request.Form.Get("checkUser")
|
||||||
applicationId := c.Ctx.Request.Form.Get("applicationId")
|
applicationId := c.Ctx.Request.Form.Get("applicationId")
|
||||||
|
method := c.Ctx.Request.Form.Get("method")
|
||||||
remoteAddr := util.GetIPFromRequest(c.Ctx.Request)
|
remoteAddr := util.GetIPFromRequest(c.Ctx.Request)
|
||||||
|
|
||||||
if destType == "" {
|
if destType == "" {
|
||||||
@ -119,7 +120,7 @@ func (c *ApiController) SendVerificationCode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userByEmail := object.GetUserByEmail(organization.Name, dest)
|
userByEmail := object.GetUserByEmail(organization.Name, dest)
|
||||||
if userByEmail == nil {
|
if userByEmail == nil && method != "signup" && method != "reset" {
|
||||||
c.ResponseError(c.T("verification:the user does not exist, please sign up first"))
|
c.ResponseError(c.T("verification:the user does not exist, please sign up first"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -136,7 +137,7 @@ func (c *ApiController) SendVerificationCode() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
userByPhone := object.GetUserByPhone(organization.Name, dest)
|
userByPhone := object.GetUserByPhone(organization.Name, dest)
|
||||||
if userByPhone == nil {
|
if userByPhone == nil && method != "signup" && method != "reset" {
|
||||||
c.ResponseError(c.T("verification:the user does not exist, please sign up first"))
|
c.ResponseError(c.T("verification:the user does not exist, please sign up first"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -92,6 +92,7 @@ export const ResetModal = (props) => {
|
|||||||
<CountDownInput
|
<CountDownInput
|
||||||
textBefore={i18next.t("code:Code You Received")}
|
textBefore={i18next.t("code:Code You Received")}
|
||||||
onChange={setCode}
|
onChange={setCode}
|
||||||
|
method={"reset"}
|
||||||
onButtonClickArgs={[dest, destType, Setting.getApplicationName(application)]}
|
onButtonClickArgs={[dest, destType, Setting.getApplicationName(application)]}
|
||||||
application={application}
|
application={application}
|
||||||
/>
|
/>
|
||||||
|
@ -355,12 +355,14 @@ class ForgetPage extends React.Component {
|
|||||||
{this.state.verifyType === "email" ? (
|
{this.state.verifyType === "email" ? (
|
||||||
<CountDownInput
|
<CountDownInput
|
||||||
disabled={this.state.username === "" || this.state.verifyType === ""}
|
disabled={this.state.username === "" || this.state.verifyType === ""}
|
||||||
|
method={"forget"}
|
||||||
onButtonClickArgs={[this.state.email, "email", Setting.getApplicationName(this.state.application), this.state.name]}
|
onButtonClickArgs={[this.state.email, "email", Setting.getApplicationName(this.state.application), this.state.name]}
|
||||||
application={application}
|
application={application}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<CountDownInput
|
<CountDownInput
|
||||||
disabled={this.state.username === "" || this.state.verifyType === ""}
|
disabled={this.state.username === "" || this.state.verifyType === ""}
|
||||||
|
method={"forget"}
|
||||||
onButtonClickArgs={[this.state.phone, "phone", Setting.getApplicationName(this.state.application), this.state.name]}
|
onButtonClickArgs={[this.state.phone, "phone", Setting.getApplicationName(this.state.application), this.state.name]}
|
||||||
application={application}
|
application={application}
|
||||||
/>
|
/>
|
||||||
|
@ -725,6 +725,7 @@ class LoginPage extends React.Component {
|
|||||||
>
|
>
|
||||||
<CountDownInput
|
<CountDownInput
|
||||||
disabled={this.state.username?.length === 0 || !this.state.validEmailOrPhone}
|
disabled={this.state.username?.length === 0 || !this.state.validEmailOrPhone}
|
||||||
|
method={"login"}
|
||||||
onButtonClickArgs={[this.state.username, this.state.validEmail ? "email" : "phone", Setting.getApplicationName(application)]}
|
onButtonClickArgs={[this.state.username, this.state.validEmail ? "email" : "phone", Setting.getApplicationName(application)]}
|
||||||
application={application}
|
application={application}
|
||||||
/>
|
/>
|
||||||
|
@ -373,6 +373,7 @@ class SignupPage extends React.Component {
|
|||||||
>
|
>
|
||||||
<CountDownInput
|
<CountDownInput
|
||||||
disabled={!this.state.validEmail}
|
disabled={!this.state.validEmail}
|
||||||
|
method={"signup"}
|
||||||
onButtonClickArgs={[this.state.email, "email", Setting.getApplicationName(application)]}
|
onButtonClickArgs={[this.state.email, "email", Setting.getApplicationName(application)]}
|
||||||
application={application}
|
application={application}
|
||||||
/>
|
/>
|
||||||
@ -426,6 +427,7 @@ class SignupPage extends React.Component {
|
|||||||
>
|
>
|
||||||
<CountDownInput
|
<CountDownInput
|
||||||
disabled={!this.state.validPhone}
|
disabled={!this.state.validPhone}
|
||||||
|
method={"signup"}
|
||||||
onButtonClickArgs={[this.state.phone, "phone", Setting.getApplicationName(application)]}
|
onButtonClickArgs={[this.state.phone, "phone", Setting.getApplicationName(application)]}
|
||||||
application={application}
|
application={application}
|
||||||
/>
|
/>
|
||||||
|
@ -109,11 +109,12 @@ export function setPassword(userOwner, userName, oldPassword, newPassword) {
|
|||||||
}).then(res => res.json());
|
}).then(res => res.json());
|
||||||
}
|
}
|
||||||
|
|
||||||
export function sendCode(checkType, checkId, checkKey, dest, type, applicationId, checkUser) {
|
export function sendCode(checkType, checkId, checkKey, method, dest, type, applicationId, checkUser) {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append("checkType", checkType);
|
formData.append("checkType", checkType);
|
||||||
formData.append("checkId", checkId);
|
formData.append("checkId", checkId);
|
||||||
formData.append("checkKey", checkKey);
|
formData.append("checkKey", checkKey);
|
||||||
|
formData.append("method", method);
|
||||||
formData.append("dest", dest);
|
formData.append("dest", dest);
|
||||||
formData.append("type", type);
|
formData.append("type", type);
|
||||||
formData.append("applicationId", applicationId);
|
formData.append("applicationId", applicationId);
|
||||||
|
@ -22,7 +22,7 @@ import {CaptchaWidget} from "./CaptchaWidget";
|
|||||||
const {Search} = Input;
|
const {Search} = Input;
|
||||||
|
|
||||||
export const CountDownInput = (props) => {
|
export const CountDownInput = (props) => {
|
||||||
const {disabled, textBefore, onChange, onButtonClickArgs, application} = props;
|
const {disabled, textBefore, onChange, onButtonClickArgs, application, method} = props;
|
||||||
const [visible, setVisible] = React.useState(false);
|
const [visible, setVisible] = React.useState(false);
|
||||||
const [key, setKey] = React.useState("");
|
const [key, setKey] = React.useState("");
|
||||||
const [captchaImg, setCaptchaImg] = React.useState("");
|
const [captchaImg, setCaptchaImg] = React.useState("");
|
||||||
@ -53,7 +53,7 @@ export const CountDownInput = (props) => {
|
|||||||
const handleOk = () => {
|
const handleOk = () => {
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
setButtonLoading(true);
|
setButtonLoading(true);
|
||||||
UserBackend.sendCode(checkType, checkId, key, ...onButtonClickArgs).then(res => {
|
UserBackend.sendCode(checkType, checkId, key, method, ...onButtonClickArgs).then(res => {
|
||||||
setKey("");
|
setKey("");
|
||||||
setButtonLoading(false);
|
setButtonLoading(false);
|
||||||
if (res) {
|
if (res) {
|
||||||
@ -70,7 +70,7 @@ export const CountDownInput = (props) => {
|
|||||||
const loadCaptcha = () => {
|
const loadCaptcha = () => {
|
||||||
UserBackend.getCaptcha(application.owner, application.name, false).then(res => {
|
UserBackend.getCaptcha(application.owner, application.name, false).then(res => {
|
||||||
if (res.type === "none") {
|
if (res.type === "none") {
|
||||||
UserBackend.sendCode("none", "", "", ...onButtonClickArgs).then(res => {
|
UserBackend.sendCode("none", "", "", method, ...onButtonClickArgs).then(res => {
|
||||||
if (res) {
|
if (res) {
|
||||||
handleCountDown(60);
|
handleCountDown(60);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user