mirror of
https://github.com/element-hq/dendrite.git
synced 2025-09-13 21:02:25 +03:00
minor refactoring
This commit is contained in:
parent
48f3cd3367
commit
9b064b1572
2 changed files with 5 additions and 16 deletions
|
@ -814,12 +814,7 @@ func AdminAllowCrossSigningReplacementWithoutUIA(
|
||||||
}
|
}
|
||||||
var rs userapi.PerformAllowingMasterCrossSigningKeyReplacementWithoutUIAResponse
|
var rs userapi.PerformAllowingMasterCrossSigningKeyReplacementWithoutUIAResponse
|
||||||
err = userAPI.PerformAllowingMasterCrossSigningKeyReplacementWithoutUIA(req.Context(), &rq, &rs)
|
err = userAPI.PerformAllowingMasterCrossSigningKeyReplacementWithoutUIA(req.Context(), &rq, &rs)
|
||||||
if err == sql.ErrNoRows {
|
if err != nil && err != sql.ErrNoRows {
|
||||||
return util.JSONResponse{
|
|
||||||
Code: http.StatusNotFound,
|
|
||||||
JSON: spec.MissingParam("User has no master cross-signing key"),
|
|
||||||
}
|
|
||||||
} else if err != nil {
|
|
||||||
util.GetLogger(req.Context()).WithError(err).Error("userAPI.PerformAllowingMasterCrossSigningKeyReplacementWithoutUIA")
|
util.GetLogger(req.Context()).WithError(err).Error("userAPI.PerformAllowingMasterCrossSigningKeyReplacementWithoutUIA")
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusInternalServerError,
|
Code: http.StatusInternalServerError,
|
||||||
|
@ -858,20 +853,14 @@ type adminCreateOrModifyAccountRequest struct {
|
||||||
// Locked bool `json:"locked"`
|
// 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())
|
logger := util.GetLogger(req.Context())
|
||||||
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
return util.MessageResponse(http.StatusBadRequest, err.Error())
|
||||||
}
|
}
|
||||||
userID, ok := vars["userID"]
|
userID, _ := vars["userID"]
|
||||||
if !ok {
|
local, domain, err := userutil.ParseUsernameParam(userID, cfg.Matrix)
|
||||||
return util.JSONResponse{
|
|
||||||
Code: http.StatusBadRequest,
|
|
||||||
JSON: spec.MissingParam("Expecting user ID."),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
local, domain, err := gomatrixserverlib.SplitID('@', userID)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.JSONResponse{
|
return util.JSONResponse{
|
||||||
Code: http.StatusBadRequest,
|
Code: http.StatusBadRequest,
|
||||||
|
|
|
@ -352,7 +352,7 @@ func Setup(
|
||||||
case http.MethodGet:
|
case http.MethodGet:
|
||||||
return AdminRetrieveAccount(r, cfg, userAPI)
|
return AdminRetrieveAccount(r, cfg, userAPI)
|
||||||
case http.MethodPut:
|
case http.MethodPut:
|
||||||
return AdminCreateOrModifyAccount(r, userAPI)
|
return AdminCreateOrModifyAccount(r, userAPI, cfg)
|
||||||
default:
|
default:
|
||||||
return util.JSONResponse{Code: http.StatusMethodNotAllowed, JSON: nil}
|
return util.JSONResponse{Code: http.StatusMethodNotAllowed, JSON: nil}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue