Verified Commit c8f3ea2e authored by Kevin Morris's avatar Kevin Morris
Browse files

fix(fastapi): fix various pkgbase-wise auth redirects



Signed-off-by: Kevin Morris's avatarKevin Morris <kevr@0cost.org>
parent fb0f252b
...@@ -774,7 +774,7 @@ async def requests_close_post(request: Request, id: int, ...@@ -774,7 +774,7 @@ async def requests_close_post(request: Request, id: int,
@router.get("/pkgbase/{name}/flag") @router.get("/pkgbase/{name}/flag")
@auth_required(True, redirect="/pkgbase/{name}") @auth_required(True, redirect="/pkgbase/{name}/flag")
async def pkgbase_flag_get(request: Request, name: str): async def pkgbase_flag_get(request: Request, name: str):
pkgbase = get_pkg_or_base(name, models.PackageBase) pkgbase = get_pkg_or_base(name, models.PackageBase)
...@@ -789,7 +789,7 @@ async def pkgbase_flag_get(request: Request, name: str): ...@@ -789,7 +789,7 @@ async def pkgbase_flag_get(request: Request, name: str):
@router.post("/pkgbase/{name}/flag") @router.post("/pkgbase/{name}/flag")
@auth_required(True, redirect="/pkgbase/{name}") @auth_required(True, redirect="/pkgbase/{name}/flag")
async def pkgbase_flag_post(request: Request, name: str, async def pkgbase_flag_post(request: Request, name: str,
comments: str = Form(default=str())): comments: str = Form(default=str())):
pkgbase = get_pkg_or_base(name, models.PackageBase) pkgbase = get_pkg_or_base(name, models.PackageBase)
...@@ -949,7 +949,7 @@ def disown_pkgbase(pkgbase: models.PackageBase, disowner: models.User): ...@@ -949,7 +949,7 @@ def disown_pkgbase(pkgbase: models.PackageBase, disowner: models.User):
@router.get("/pkgbase/{name}/disown") @router.get("/pkgbase/{name}/disown")
@auth_required(True, redirect="/pkgbase/{name}") @auth_required(True, redirect="/pkgbase/{name}/disown")
async def pkgbase_disown_get(request: Request, name: str): async def pkgbase_disown_get(request: Request, name: str):
pkgbase = get_pkg_or_base(name, models.PackageBase) pkgbase = get_pkg_or_base(name, models.PackageBase)
...@@ -965,7 +965,7 @@ async def pkgbase_disown_get(request: Request, name: str): ...@@ -965,7 +965,7 @@ async def pkgbase_disown_get(request: Request, name: str):
@router.post("/pkgbase/{name}/disown") @router.post("/pkgbase/{name}/disown")
@auth_required(True, redirect="/pkgbase/{name}") @auth_required(True, redirect="/pkgbase/{name}/disown")
async def pkgbase_disown_post(request: Request, name: str, async def pkgbase_disown_post(request: Request, name: str,
confirm: bool = Form(default=False)): confirm: bool = Form(default=False)):
pkgbase = get_pkg_or_base(name, models.PackageBase) pkgbase = get_pkg_or_base(name, models.PackageBase)
...@@ -990,7 +990,7 @@ async def pkgbase_disown_post(request: Request, name: str, ...@@ -990,7 +990,7 @@ async def pkgbase_disown_post(request: Request, name: str,
@router.post("/pkgbase/{name}/adopt") @router.post("/pkgbase/{name}/adopt")
@auth_required(True) @auth_required(True, redirect="/pkgbase/{name}")
async def pkgbase_adopt_post(request: Request, name: str): async def pkgbase_adopt_post(request: Request, name: str):
pkgbase = get_pkg_or_base(name, models.PackageBase) pkgbase = get_pkg_or_base(name, models.PackageBase)
...@@ -1007,7 +1007,7 @@ async def pkgbase_adopt_post(request: Request, name: str): ...@@ -1007,7 +1007,7 @@ async def pkgbase_adopt_post(request: Request, name: str):
@router.get("/pkgbase/{name}/delete") @router.get("/pkgbase/{name}/delete")
@auth_required(True) @auth_required(True, redirect="/pkgbase/{name}/delete")
async def pkgbase_delete_get(request: Request, name: str): async def pkgbase_delete_get(request: Request, name: str):
if not request.user.has_credential("CRED_PKGBASE_DELETE"): if not request.user.has_credential("CRED_PKGBASE_DELETE"):
return RedirectResponse(f"/pkgbase/{name}", return RedirectResponse(f"/pkgbase/{name}",
...@@ -1019,7 +1019,7 @@ async def pkgbase_delete_get(request: Request, name: str): ...@@ -1019,7 +1019,7 @@ async def pkgbase_delete_get(request: Request, name: str):
@router.post("/pkgbase/{name}/delete") @router.post("/pkgbase/{name}/delete")
@auth_required(True) @auth_required(True, redirect="/pkgbase/{name}/delete")
async def pkgbase_delete_post(request: Request, name: str, async def pkgbase_delete_post(request: Request, name: str,
confirm: bool = Form(default=False)): confirm: bool = Form(default=False)):
pkgbase = get_pkg_or_base(name, models.PackageBase) pkgbase = get_pkg_or_base(name, models.PackageBase)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment