diff --git a/atst/routes/__init__.py b/atst/routes/__init__.py index 0ea12952..214fb35c 100644 --- a/atst/routes/__init__.py +++ b/atst/routes/__init__.py @@ -97,8 +97,10 @@ def _make_authentication_context(): def redirect_after_login_url(): if request.args.get("next"): returl = request.args.get("next") - if request.args.get("formCache"): - returl += "?" + url.urlencode({"formCache": request.args.get("formCache")}) + if request.args.get(app.form_cache.PARAM_NAME): + returl += "?" + url.urlencode( + {app.form_cache.PARAM_NAME: request.args.get(app.form_cache.PARAM_NAME)} + ) return returl else: return url_for("atst.home") diff --git a/atst/routes/errors.py b/atst/routes/errors.py index 039ae635..3f32b110 100644 --- a/atst/routes/errors.py +++ b/atst/routes/errors.py @@ -39,7 +39,7 @@ def make_error_pages(app): log_error(e) url_args = {"sessionExpired": True, "next": request.path} if request.method == "POST": - url_args["formCache"] = app.form_cache.write(request.form) + url_args[app.form_cache.PARAM_NAME] = app.form_cache.write(request.form) return redirect(url_for("atst.root", **url_args)) @app.errorhandler(Exception) diff --git a/atst/utils/form_cache.py b/atst/utils/form_cache.py index 3ce4f17a..c7ac6d80 100644 --- a/atst/utils/form_cache.py +++ b/atst/utils/form_cache.py @@ -7,11 +7,13 @@ DEFAULT_CACHE_NAME = "formcache" class FormCache(object): + PARAM_NAME = "formCache" + def __init__(self, redis): self.redis = redis def from_request(self, http_request): - cache_key = http_request.args.get("formCache") + cache_key = http_request.args.get(self.PARAM_NAME) if cache_key: return self.read(cache_key)