HNT-105 invite authz

This commit is contained in:
John Terzis 2022-10-21 16:57:20 -07:00 committed by Tak Wai Wong
parent 94061b7b8d
commit 36039c2efc
No known key found for this signature in database
GPG key ID: 222E4AF2AA1F467D

View file

@ -353,6 +353,19 @@ func Setup(
return util.ErrorResponse(err)
}
isAllowedInviter, _ := authorization.IsAllowed(authz.AuthorizationArgs{
RoomId: vars["roomID"],
UserId: device.UserID,
Permission: authz.PermissionInvite,
})
if !isAllowedInviter {
return util.JSONResponse{
Code: http.StatusUnauthorized,
JSON: jsonerror.Forbidden("Inviter not allowed"),
}
}
return SendInvite(req, userAPI, device, vars["roomID"], cfg, rsAPI, asAPI)
}),
).Methods(http.MethodPost, http.MethodOptions)