mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
New request.cookies property
This commit is contained in:
parent
b4cd8797b8
commit
1d0bea157a
3 changed files with 12 additions and 7 deletions
|
|
@ -5,14 +5,9 @@ from http.cookies import SimpleCookie
|
|||
|
||||
@hookimpl
|
||||
def actor_from_request(datasette, request):
|
||||
cookies = SimpleCookie()
|
||||
cookies.load(
|
||||
dict(request.scope.get("headers") or []).get(b"cookie", b"").decode("utf-8")
|
||||
)
|
||||
if "ds_actor" not in cookies:
|
||||
if "ds_actor" not in request.cookies:
|
||||
return None
|
||||
ds_actor = cookies["ds_actor"].value
|
||||
try:
|
||||
return datasette.unsign(ds_actor, "actor")
|
||||
return datasette.unsign(request.cookies["ds_actor"], "actor")
|
||||
except BadSignature:
|
||||
return None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue