fix(routers.packages): restrict /pkgbase/{name}/voters to those with creds

Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
Kevin Morris 2021-12-19 14:48:40 -08:00
parent 0c07c14860
commit 22093c5c38
No known key found for this signature in database
GPG key ID: F7E46DED420788F3
3 changed files with 30 additions and 8 deletions

View file

@ -254,6 +254,11 @@ async def package_base(request: Request, name: str) -> Response:
async def package_base_voters(request: Request, name: str) -> Response:
# Get the PackageBase.
pkgbase = get_pkg_or_base(name, models.PackageBase)
if not request.user.has_credential(creds.PKGBASE_LIST_VOTERS):
return RedirectResponse(f"/pkgbase/{name}",
status_code=HTTPStatus.SEE_OTHER)
context = make_context(request, "Voters")
context["pkgbase"] = pkgbase
return render_template(request, "pkgbase/voters.html", context)