Redirects
rn_forge.auth.redirects
Validation of the post-login return_to target.
InvalidReturnTo(reason)
Bases: AppException
A return_to value is not an allowed relative path.
Callers catch it and fall back to a default target.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reason
|
str
|
A short description of the rule the value broke. |
required |
check(value, message, *message_args, **kwargs)
classmethod
Raise this exception if value is falsy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The value to test. |
required |
message
|
str
|
Exception message (supports positional format args). |
required |
*message_args
|
Any
|
Forwarded to |
()
|
**kwargs
|
Any
|
Forwarded as |
{}
|
Example::
AppException.check(path.exists(), "Missing file: {}", path, error_code=404)
validate_return_to(value, *, prefixes)
Return value when it is a relative path under one of prefixes.
A prefix matches whole path segments: /app allows /app and
/app/x but not /apple, and / allows every path. A query string
or fragment may follow the path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
The candidate target. |
required |
prefixes
|
Sequence[str]
|
Allowed path prefixes, each starting with |
required |
Returns:
| Type | Description |
|---|---|
str
|
value, unchanged. |
Raises:
| Type | Description |
|---|---|
InvalidReturnTo
|
value is empty, is not a path starting with a single
|