mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-10 00:03:24 +00:00
fix missing HTTP_REFERER
This commit is contained in:
parent
e37ce4172e
commit
f6fbad8403
@ -23,13 +23,12 @@ def is_logged_in_counter(request: HttpRequest) -> bool:
|
|||||||
- The current session has a counter token associated with it.
|
- The current session has a counter token associated with it.
|
||||||
- A counter with this token exists.
|
- A counter with this token exists.
|
||||||
"""
|
"""
|
||||||
referer = urlparse(request.META["HTTP_REFERER"]).path
|
referer_ok = (
|
||||||
path_ok = (
|
"HTTP_REFERER" in request.META
|
||||||
request.resolver_match.app_name == "counter"
|
and resolve(urlparse(request.META["HTTP_REFERER"]).path).app_name == "counter"
|
||||||
or resolve(referer).app_name == "counter"
|
|
||||||
)
|
)
|
||||||
return (
|
return (
|
||||||
path_ok
|
(referer_ok or request.resolver_match.app_name == "counter")
|
||||||
and "counter_token" in request.session
|
and "counter_token" in request.session
|
||||||
and request.session["counter_token"]
|
and request.session["counter_token"]
|
||||||
and Counter.objects.filter(token=request.session["counter_token"]).exists()
|
and Counter.objects.filter(token=request.session["counter_token"]).exists()
|
||||||
|
Loading…
Reference in New Issue
Block a user