mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-06 13:43:09 -06:00
Guard endpoint
This commit is contained in:
parent
87c1dae4ae
commit
7359617c1c
|
|
@ -122,6 +122,19 @@ func Setup(
|
||||||
|
|
||||||
synapseAdminRouter.Handle("/admin/evacuateRoom",
|
synapseAdminRouter.Handle("/admin/evacuateRoom",
|
||||||
httputil.MakeExternalAPI("admin_evacuate_room", func(req *http.Request) util.JSONResponse {
|
httputil.MakeExternalAPI("admin_evacuate_room", func(req *http.Request) util.JSONResponse {
|
||||||
|
device, err := getSenderDevice(context.Background(), userAPI, cfg)
|
||||||
|
if err != nil {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: http.StatusForbidden,
|
||||||
|
JSON: jsonerror.Forbidden("Couldn't determine if you were an admin or not."),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if device.AccountType != userapi.AccountTypeAdmin {
|
||||||
|
return util.JSONResponse{
|
||||||
|
Code: http.StatusForbidden,
|
||||||
|
JSON: jsonerror.Forbidden("This API can only be used by admin users."),
|
||||||
|
}
|
||||||
|
}
|
||||||
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
vars, err := httputil.URLDecodeMapValues(mux.Vars(req))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return util.ErrorResponse(err)
|
return util.ErrorResponse(err)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue