fix: url_for should not return extension upgrades temp paths (#3227)
This commit is contained in:
parent
b4b37cd733
commit
ab3248da15
1 changed files with 14 additions and 1 deletions
|
|
@ -28,7 +28,7 @@ from lnbits.core.models import (
|
|||
WalletTypeInfo,
|
||||
)
|
||||
from lnbits.db import Connection, Filter, Filters, TFilterModel
|
||||
from lnbits.helpers import path_segments
|
||||
from lnbits.helpers import normalize_path, path_segments
|
||||
from lnbits.settings import AuthMethods, settings
|
||||
|
||||
oauth2_scheme = OAuth2PasswordBearer(
|
||||
|
|
@ -346,3 +346,16 @@ async def _check_account_api_access(
|
|||
raise HTTPException(HTTPStatus.FORBIDDEN, "Path not allowed.")
|
||||
if not endpoint.supports_method(method):
|
||||
raise HTTPException(HTTPStatus.FORBIDDEN, "Method not allowed.")
|
||||
|
||||
|
||||
def url_for_interceptor(original_method):
|
||||
def normalize_url(self, *args, **kwargs):
|
||||
url = original_method(self, *args, **kwargs)
|
||||
return url.replace(path=normalize_path(url.path))
|
||||
|
||||
return normalize_url
|
||||
|
||||
|
||||
# Upgraded extensions modify the path.
|
||||
# This interceptor ensures that the path is normalized.
|
||||
Request.url_for = url_for_interceptor(Request.url_for) # type: ignore[method-assign]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue