Fix error handling in SetPassword()

This commit is contained in:
Yang Luo
2023-06-22 14:46:38 +08:00
parent 2c2ddfbb92
commit b817a55f9f

View File

@ -416,6 +416,7 @@ func (c *ApiController) SetPassword() {
requestUserId := c.GetSessionUsername() requestUserId := c.GetSessionUsername()
if requestUserId == "" && code == "" { if requestUserId == "" && code == "" {
c.ResponseError(c.T("general:Please login first"), "Please login first")
return return
} else if code == "" { } else if code == "" {
hasPermission, err := object.CheckUserPermission(requestUserId, userId, true, c.GetAcceptLanguage()) hasPermission, err := object.CheckUserPermission(requestUserId, userId, true, c.GetAcceptLanguage())
@ -425,7 +426,7 @@ func (c *ApiController) SetPassword() {
} }
} else { } else {
if code != c.GetSession("verifiedCode") { if code != c.GetSession("verifiedCode") {
c.ResponseError("") c.ResponseError(c.T("general:Missing parameter"))
return return
} }
c.SetSession("verifiedCode", "") c.SetSession("verifiedCode", "")