diff --git a/vibora/request/request.pyx b/vibora/request/request.pyx index 2a451da..2a17244 100644 --- a/vibora/request/request.pyx +++ b/vibora/request/request.pyx @@ -160,7 +160,7 @@ cdef class Request: :return: """ if not self._session: - self._session = await self.app.session_engine.load(self.cookies) + self._session = await self.app.session_engine.load(self) return self._session async def json(self, loads=None, strict: bool=False) -> dict: diff --git a/vibora/sessions/base.py b/vibora/sessions/base.py index 463fa2e..3ec4130 100644 --- a/vibora/sessions/base.py +++ b/vibora/sessions/base.py @@ -8,7 +8,7 @@ def __init__(self, cookie_name: str = None): async def load(self, request): raise NotImplementedError - async def save(self, request, response): + async def save(self, pending_session, response): raise NotImplementedError async def clean_up(self): diff --git a/vibora/sessions/client.py b/vibora/sessions/client.py index f77047c..ccf2b41 100644 --- a/vibora/sessions/client.py +++ b/vibora/sessions/client.py @@ -45,7 +45,7 @@ async def load(self, request) -> Session: return Session(pending_flush=True) return Session() - async def save(self, request, response) -> None: + async def save(self, pending_session, response) -> None: """ Inject headers in the response object so the user will receive an encrypted cookie with session values. @@ -53,6 +53,6 @@ async def save(self, request, response) -> None: :param response: current Response object where headers will be inject. :return: """ - value = self.cipher.encrypt(request.session.dumps().encode()) + value = self.cipher.encrypt(pending_session.dumps().encode()) cookie = f"{self.cookie_name}={value.decode()}; SameSite=Lax" response.headers["Set-Cookie"] = cookie