Added the "decode_next" utility in the "accounting.utils.next_uri" module, and applied the "encode_next" and "decode_next" utilities to the NextUriTestCase test case, so that the test case do not need to get involved into the detail of the next URI encryption.
This commit is contained in:
@ -75,8 +75,7 @@ def __get_next() -> str | None:
|
||||
if next_uri is None:
|
||||
return None
|
||||
try:
|
||||
return URLSafeSerializer(current_app.config["SECRET_KEY"])\
|
||||
.loads(next_uri, "next")
|
||||
return decode_next(next_uri)
|
||||
except BadData:
|
||||
return None
|
||||
|
||||
@ -107,6 +106,16 @@ def encode_next(uri: str) -> str:
|
||||
.dumps(uri, "next")
|
||||
|
||||
|
||||
def decode_next(uri: str) -> str:
|
||||
"""Decodes the encoded next URI.
|
||||
|
||||
:param uri: The encoded next URI.
|
||||
:return: The next URI.
|
||||
"""
|
||||
return URLSafeSerializer(current_app.config["SECRET_KEY"])\
|
||||
.loads(uri, "next")
|
||||
|
||||
|
||||
def init_app(bp: Blueprint) -> None:
|
||||
"""Initializes the application.
|
||||
|
||||
|
Reference in New Issue
Block a user