fix(auth): pass request as keyword arg in require_login to fix path-param endpoints

Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-08 10:05:50 +00:00
parent d03991f7e1
commit 7db26f4a31
2 changed files with 50 additions and 5 deletions
+6 -3
View File
@@ -83,11 +83,14 @@ def require_login(func):
if not request.session.get("user"):
request.session["redirect_after_login"] = str(request.url)
return RedirectResponse(url="/login", status_code=status.HTTP_302_FOUND)
# Check if the wrapped function is a coroutine function
# Pass request as a keyword argument so that endpoints whose first
# parameter is a path variable (e.g. pipeline_id) are not accidentally
# bound to the request object when FastAPI supplies all arguments as
# keyword arguments.
if inspect.iscoroutinefunction(func):
return await func(request, *args, **kwargs)
return await func(*args, request=request, **kwargs)
else:
return func(request, *args, **kwargs)
return func(*args, request=request, **kwargs)
return wrapper