diff --git a/controllers/verification.go b/controllers/verification.go
index 615fad86..b6c2cc75 100644
--- a/controllers/verification.go
+++ b/controllers/verification.go
@@ -42,14 +42,14 @@ func (c *ApiController) getCurrentUser() *object.User {
func (c *ApiController) SendVerificationCode() {
destType := c.Ctx.Request.Form.Get("type")
dest := c.Ctx.Request.Form.Get("dest")
- orgId := c.Ctx.Request.Form.Get("organizationId")
checkType := c.Ctx.Request.Form.Get("checkType")
checkId := c.Ctx.Request.Form.Get("checkId")
checkKey := c.Ctx.Request.Form.Get("checkKey")
checkUser := c.Ctx.Request.Form.Get("checkUser")
+ applicationId := c.Ctx.Request.Form.Get("applicationId")
remoteAddr := util.GetIPFromRequest(c.Ctx.Request)
- if len(destType) == 0 || len(dest) == 0 || len(orgId) == 0 || !strings.Contains(orgId, "/") || len(checkType) == 0 {
+ if destType == "" || dest == "" || applicationId == "" || !strings.Contains(applicationId, "/") || checkType == "" {
c.ResponseError("Missing parameter.")
return
}
@@ -74,8 +74,8 @@ func (c *ApiController) SendVerificationCode() {
}
user := c.getCurrentUser()
- organization := object.GetOrganization(orgId)
- application := object.GetApplicationByOrganizationName(organization.Name)
+ application := object.GetApplication(applicationId)
+ organization := object.GetOrganization(fmt.Sprintf("%s/%s", application.Owner, application.Organization))
if checkUser == "true" && user == nil && object.GetUserByFields(organization.Name, dest) == nil {
c.ResponseError("Please login first")
@@ -85,7 +85,7 @@ func (c *ApiController) SendVerificationCode() {
sendResp := errors.New("Invalid dest type")
if user == nil && checkUser != "" && checkUser != "true" {
- _, name := util.GetOwnerAndNameFromId(orgId)
+ name := application.Organization
user = object.GetUser(fmt.Sprintf("%s/%s", name, checkUser))
}
switch destType {
@@ -108,13 +108,12 @@ func (c *ApiController) SendVerificationCode() {
c.ResponseError("Invalid phone number")
return
}
- org := object.GetOrganization(orgId)
- if org == nil {
- c.ResponseError("Missing parameter.")
+ if organization == nil {
+ c.ResponseError("The organization doesn't exist.")
return
}
- dest = fmt.Sprintf("+%s%s", org.PhonePrefix, dest)
+ dest = fmt.Sprintf("+%s%s", organization.PhonePrefix, dest)
provider := application.GetSmsProvider()
sendResp = object.SendVerificationCodeToPhone(organization, user, provider, remoteAddr, dest)
}
diff --git a/web/src/ResetModal.js b/web/src/ResetModal.js
index bc6233ce..fce545c0 100644
--- a/web/src/ResetModal.js
+++ b/web/src/ResetModal.js
@@ -25,7 +25,7 @@ export const ResetModal = (props) => {
const [confirmLoading, setConfirmLoading] = React.useState(false);
const [dest, setDest] = React.useState("");
const [code, setCode] = React.useState("");
- const {buttonText, destType, org} = props;
+ const {buttonText, destType, application} = props;
const showModal = () => {
setVisible(true);
@@ -89,7 +89,7 @@ export const ResetModal = (props) => {