(*args: _P.args, **kwargs: _P.kwargs)
| 80 | # Handle sync request/response functions. |
| 81 | @functools.wraps(func) |
| 82 | def sync_wrapper(*args: _P.args, **kwargs: _P.kwargs) -> Any: |
| 83 | request = kwargs.get("request", args[idx] if idx < len(args) else None) |
| 84 | assert isinstance(request, Request), ( |
| 85 | f"Parameter with name 'request' is required to be of type 'Request' not '{type(request).__name__}'" |
| 86 | ) |
| 87 | |
| 88 | if not has_required_scope(request, scopes_list): |
| 89 | if redirect is not None: |
| 90 | orig_request_qparam = urlencode({"next": str(request.url)}) |
| 91 | next_url = f"{request.url_for(redirect)}?{orig_request_qparam}" |
| 92 | return RedirectResponse(url=next_url, status_code=303) |
| 93 | raise HTTPException(status_code=status_code) |
| 94 | return func(*args, **kwargs) |
| 95 | |
| 96 | return sync_wrapper |
| 97 |
nothing calls this directly
no test coverage detected