From c8491a13b330e1d3e57c39cc23540e906ceb60a7 Mon Sep 17 00:00:00 2001 From: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:06:22 +0530 Subject: [PATCH] [WEB - 1827]remove: migration for account and social login connection (#5013) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: OAuth adapter error codes + missing account provider migration that introduces GitLab (#4998) * feat(apiserver): GitLab OAuth client * feat(admin,packages,space,web): GitLab OAuth client * Feat(apiserver/oauth): authentication_error_code() * chore: remove empty files introduced by rebase * dev: delete migration --------- Co-authored-by: jon ⚝ --- .../plane/authentication/adapter/oauth.py | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/apiserver/plane/authentication/adapter/oauth.py b/apiserver/plane/authentication/adapter/oauth.py index 1878126d9..ffda0212f 100644 --- a/apiserver/plane/authentication/adapter/oauth.py +++ b/apiserver/plane/authentication/adapter/oauth.py @@ -39,6 +39,16 @@ class OauthAdapter(Adapter): self.client_secret = client_secret self.code = code + def authentication_error_code(self): + if self.provider == "google": + return "GOOGLE_OAUTH_PROVIDER_ERROR" + elif self.provider == "github": + return "GITHUB_OAUTH_PROVIDER_ERROR" + elif self.provider == "gitlab": + return "GITLAB_OAUTH_PROVIDER_ERROR" + else: + return "OAUTH_NOT_CONFIGURED" + def get_auth_url(self): return self.auth_url @@ -62,7 +72,7 @@ class OauthAdapter(Adapter): response.raise_for_status() return response.json() except requests.RequestException: - code = self._provider_error_code() + code = self.authentication_error_code() raise AuthenticationException( error_code=AUTHENTICATION_ERROR_CODES[code], error_message=str(code), @@ -77,15 +87,7 @@ class OauthAdapter(Adapter): response.raise_for_status() return response.json() except requests.RequestException: - if self.provider == "google": - code = "GOOGLE_OAUTH_PROVIDER_ERROR" - elif self.provider == "github": - code = "GITHUB_OAUTH_PROVIDER_ERROR" - elif self.provider == "gitlab": - code = "GITLAB_OAUTH_PROVIDER_ERROR" - else: - code = "OAUTH_NOT_CONFIGURED" - + code = self.authentication_error_code() raise AuthenticationException( error_code=AUTHENTICATION_ERROR_CODES[code], error_message=str(code),