From cbca2c78ee88b98a32a891dd60dd59c015a76615 Mon Sep 17 00:00:00 2001 From: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Date: Fri, 17 May 2024 19:39:40 +0530 Subject: [PATCH] [WEB - 1370] dev: remove session save and add callback for providers (#4506) * dev: remove session save and add callback for providers * dev: make session save every request as env variable --- apiserver/plane/authentication/adapter/credential.py | 2 +- apiserver/plane/authentication/adapter/oauth.py | 2 +- apiserver/plane/authentication/provider/credentials/email.py | 4 +++- .../plane/authentication/provider/credentials/magic_code.py | 4 +++- apiserver/plane/settings/common.py | 4 +++- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/apiserver/plane/authentication/adapter/credential.py b/apiserver/plane/authentication/adapter/credential.py index 943e6b068..0327289ca 100644 --- a/apiserver/plane/authentication/adapter/credential.py +++ b/apiserver/plane/authentication/adapter/credential.py @@ -5,7 +5,7 @@ class CredentialAdapter(Adapter): """Common interface for all credential providers""" def __init__(self, request, provider, callback=None): - super().__init__(request, provider, callback) + super().__init__(request=request, provider=provider, callback=callback) self.request = request self.provider = provider diff --git a/apiserver/plane/authentication/adapter/oauth.py b/apiserver/plane/authentication/adapter/oauth.py index 634b42077..b841db99d 100644 --- a/apiserver/plane/authentication/adapter/oauth.py +++ b/apiserver/plane/authentication/adapter/oauth.py @@ -25,7 +25,7 @@ class OauthAdapter(Adapter): code=None, callback=None, ): - super().__init__(request, provider, callback=callback) + super().__init__(request=request, provider=provider, callback=callback) self.client_id = client_id self.scope = scope self.redirect_uri = redirect_uri diff --git a/apiserver/plane/authentication/provider/credentials/email.py b/apiserver/plane/authentication/provider/credentials/email.py index eae3ea932..7e4e619d8 100644 --- a/apiserver/plane/authentication/provider/credentials/email.py +++ b/apiserver/plane/authentication/provider/credentials/email.py @@ -23,7 +23,9 @@ class EmailProvider(CredentialAdapter): is_signup=False, callback=None, ): - super().__init__(request, self.provider) + super().__init__( + request=request, provider=self.provider, callback=callback + ) self.key = key self.code = code self.is_signup = is_signup diff --git a/apiserver/plane/authentication/provider/credentials/magic_code.py b/apiserver/plane/authentication/provider/credentials/magic_code.py index 68322c5d6..9c199c4df 100644 --- a/apiserver/plane/authentication/provider/credentials/magic_code.py +++ b/apiserver/plane/authentication/provider/credentials/magic_code.py @@ -59,7 +59,9 @@ class MagicCodeProvider(CredentialAdapter): payload={"email": str(self.key)}, ) - super().__init__(request, self.provider) + super().__init__( + request=request, provider=self.provider, callback=callback + ) self.key = key self.code = code diff --git a/apiserver/plane/settings/common.py b/apiserver/plane/settings/common.py index 89696403e..a5611fdab 100644 --- a/apiserver/plane/settings/common.py +++ b/apiserver/plane/settings/common.py @@ -331,7 +331,9 @@ SESSION_ENGINE = "plane.db.models.session" SESSION_COOKIE_AGE = os.environ.get("SESSION_COOKIE_AGE", 604800) SESSION_COOKIE_NAME = "plane-session-id" SESSION_COOKIE_DOMAIN = os.environ.get("COOKIE_DOMAIN", None) -SESSION_SAVE_EVERY_REQUEST = True +SESSION_SAVE_EVERY_REQUEST = ( + os.environ.get("SESSION_SAVE_EVERY_REQUEST", "0") == "1" +) # Admin Cookie ADMIN_SESSION_COOKIE_NAME = "plane-admin-session-id"