refactor: Improve exception handling and logging in authentication and playlist services; enhance code readability and structure
This commit is contained in:
@@ -467,11 +467,13 @@ class AuthService:
|
||||
# If user has existing password, verify it
|
||||
if had_existing_password:
|
||||
if not current_password:
|
||||
raise ValueError("Current password is required when changing existing password")
|
||||
msg = "Current password is required when changing existing password"
|
||||
raise ValueError(msg)
|
||||
if not PasswordUtils.verify_password(current_password, user.password_hash):
|
||||
raise ValueError("Current password is incorrect")
|
||||
msg = "Current password is incorrect"
|
||||
raise ValueError(msg)
|
||||
else:
|
||||
# User doesn't have a password (OAuth-only user), so we're setting their first password
|
||||
# User doesn't have a password (OAuth-only user), setting first password
|
||||
logger.info("Setting first password for OAuth user: %s", user_email)
|
||||
|
||||
# Hash new password
|
||||
@@ -509,6 +511,6 @@ class AuthService:
|
||||
updated_at=user.updated_at,
|
||||
)
|
||||
|
||||
async def get_user_oauth_providers(self, user: User):
|
||||
async def get_user_oauth_providers(self, user: User) -> list:
|
||||
"""Get OAuth providers connected to the user."""
|
||||
return await self.oauth_repo.get_by_user_id(user.id)
|
||||
|
||||
Reference in New Issue
Block a user