From f9de3cc6389088b00c6cfe55d8deed3b034f5fc8 Mon Sep 17 00:00:00 2001 From: pablohashescobar Date: Tue, 17 Feb 2026 13:33:47 +0530 Subject: [PATCH] chore: addressed some additional comments --- .../provider/credentials/email.py | 72 ++++++++----------- .../authentication/provider/oauth/github.py | 4 +- 2 files changed, 32 insertions(+), 44 deletions(-) diff --git a/apps/api/plane/authentication/provider/credentials/email.py b/apps/api/plane/authentication/provider/credentials/email.py index dff5f88185..e2c424588a 100644 --- a/apps/api/plane/authentication/provider/credentials/email.py +++ b/apps/api/plane/authentication/provider/credentials/email.py @@ -7,11 +7,11 @@ import os # Module imports from plane.authentication.adapter.credential import CredentialAdapter -from plane.db.models import User from plane.authentication.adapter.error import ( AUTHENTICATION_ERROR_CODES, AuthenticationException, ) +from plane.db.models import User from plane.license.utils.instance_value import get_configuration_value @@ -24,14 +24,12 @@ class EmailProvider(CredentialAdapter): self.code = code self.is_signup = is_signup - (ENABLE_EMAIL_PASSWORD,) = get_configuration_value( - [ - { - "key": "ENABLE_EMAIL_PASSWORD", - "default": os.environ.get("ENABLE_EMAIL_PASSWORD"), - } - ] - ) + (ENABLE_EMAIL_PASSWORD,) = get_configuration_value([ + { + "key": "ENABLE_EMAIL_PASSWORD", + "default": os.environ.get("ENABLE_EMAIL_PASSWORD"), + } + ]) if ENABLE_EMAIL_PASSWORD == "0": raise AuthenticationException( @@ -43,35 +41,29 @@ class EmailProvider(CredentialAdapter): if self.is_signup: # Check if the user already exists if User.objects.filter(email=self.key).exists(): - self.logger.warning("User already exists", extra={ - "email": self.key, - }) + self.logger.warning("User already exists") raise AuthenticationException( error_message="USER_ALREADY_EXIST", error_code=AUTHENTICATION_ERROR_CODES["USER_ALREADY_EXIST"], ) - super().set_user_data( - { - "email": self.key, - "user": { - "avatar": "", - "first_name": "", - "last_name": "", - "provider_id": "", - "is_password_autoset": False, - }, - } - ) + super().set_user_data({ + "email": self.key, + "user": { + "avatar": "", + "first_name": "", + "last_name": "", + "provider_id": "", + "is_password_autoset": False, + }, + }) return else: user = User.objects.filter(email=self.key).first() # User does not exists if not user: - self.logger.warning("User does not exist", extra={ - "email": self.key, - }) + self.logger.warning("User does not exist") raise AuthenticationException( error_message="USER_DOES_NOT_EXIST", error_code=AUTHENTICATION_ERROR_CODES["USER_DOES_NOT_EXIST"], @@ -80,9 +72,7 @@ class EmailProvider(CredentialAdapter): # Check user password if not user.check_password(self.code): - self.logger.warning("Authentication failed", extra={ - "email": self.key, - }) + self.logger.warning("Authentication failed - invalid credentials") raise AuthenticationException( error_message=( "AUTHENTICATION_FAILED_SIGN_UP" if self.is_signup else "AUTHENTICATION_FAILED_SIGN_IN" @@ -93,16 +83,14 @@ class EmailProvider(CredentialAdapter): payload={"email": self.key}, ) - super().set_user_data( - { - "email": self.key, - "user": { - "avatar": "", - "first_name": "", - "last_name": "", - "provider_id": "", - "is_password_autoset": False, - }, - } - ) + super().set_user_data({ + "email": self.key, + "user": { + "avatar": "", + "first_name": "", + "last_name": "", + "provider_id": "", + "is_password_autoset": False, + }, + }) return diff --git a/apps/api/plane/authentication/provider/oauth/github.py b/apps/api/plane/authentication/provider/oauth/github.py index 935dba2479..363cd722e5 100644 --- a/apps/api/plane/authentication/provider/oauth/github.py +++ b/apps/api/plane/authentication/provider/oauth/github.py @@ -112,14 +112,14 @@ class GitHubOAuthProvider(OauthAdapter): emails_response = requests.get(emails_url, headers=headers).json() # Ensure the response is a list before iterating if not isinstance(emails_response, list): - self.logger.error(f"Unexpected response format from GitHub emails API: {emails_response}") + self.logger.error("Unexpected response format from GitHub emails API") raise AuthenticationException( error_code=AUTHENTICATION_ERROR_CODES["GITHUB_OAUTH_PROVIDER_ERROR"], error_message="GITHUB_OAUTH_PROVIDER_ERROR", ) email = next((email["email"] for email in emails_response if email["primary"]), None) if not email: - self.logger.error(f"No primary email found for user: {emails_response}") + self.logger.error("No primary email found for user") raise AuthenticationException( error_code=AUTHENTICATION_ERROR_CODES["GITHUB_OAUTH_PROVIDER_ERROR"], error_message="GITHUB_OAUTH_PROVIDER_ERROR",