diff --git a/clientapi/routing/admin.go b/clientapi/routing/admin.go index be865c39..fcb167e2 100644 --- a/clientapi/routing/admin.go +++ b/clientapi/routing/admin.go @@ -814,12 +814,7 @@ func AdminAllowCrossSigningReplacementWithoutUIA( } var rs userapi.PerformAllowingMasterCrossSigningKeyReplacementWithoutUIAResponse err = userAPI.PerformAllowingMasterCrossSigningKeyReplacementWithoutUIA(req.Context(), &rq, &rs) - if err == sql.ErrNoRows { - return util.JSONResponse{ - Code: http.StatusNotFound, - JSON: spec.MissingParam("User has no master cross-signing key"), - } - } else if err != nil { + if err != nil && err != sql.ErrNoRows { util.GetLogger(req.Context()).WithError(err).Error("userAPI.PerformAllowingMasterCrossSigningKeyReplacementWithoutUIA") return util.JSONResponse{ Code: http.StatusInternalServerError, @@ -858,20 +853,14 @@ type adminCreateOrModifyAccountRequest struct { // Locked bool `json:"locked"` } -func AdminCreateOrModifyAccount(req *http.Request, userAPI userapi.ClientUserAPI) util.JSONResponse { +func AdminCreateOrModifyAccount(req *http.Request, userAPI userapi.ClientUserAPI, cfg *config.ClientAPI) util.JSONResponse { logger := util.GetLogger(req.Context()) vars, err := httputil.URLDecodeMapValues(mux.Vars(req)) if err != nil { return util.MessageResponse(http.StatusBadRequest, err.Error()) } - userID, ok := vars["userID"] - if !ok { - return util.JSONResponse{ - Code: http.StatusBadRequest, - JSON: spec.MissingParam("Expecting user ID."), - } - } - local, domain, err := gomatrixserverlib.SplitID('@', userID) + userID, _ := vars["userID"] + local, domain, err := userutil.ParseUsernameParam(userID, cfg.Matrix) if err != nil { return util.JSONResponse{ Code: http.StatusBadRequest, diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 0e672f50..55a660fe 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -352,7 +352,7 @@ func Setup( case http.MethodGet: return AdminRetrieveAccount(r, cfg, userAPI) case http.MethodPut: - return AdminCreateOrModifyAccount(r, userAPI) + return AdminCreateOrModifyAccount(r, userAPI, cfg) default: return util.JSONResponse{Code: http.StatusMethodNotAllowed, JSON: nil} }