From 9b0e3ddf8821d98ed89df81f10c5b94ba92808d0 Mon Sep 17 00:00:00 2001 From: belviskhoremk Date: Wed, 27 May 2026 23:02:54 +0000 Subject: [PATCH] Fixed issues after second dev test --- .gitignore | 4 ++-- app/models/auth.py | 4 ++-- app/services/auth_service.py | 6 +++++- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index ad50443..618bc37 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ .claude/ .junie/ .agents/ - +skills-lock.json __pycache__/ *.pyc @@ -12,4 +12,4 @@ __pycache__/ .idea/ *.egg-info/ dist/ -.DS_Store +.DS_Store \ No newline at end of file diff --git a/app/models/auth.py b/app/models/auth.py index b47b3c2..8c11ca9 100644 --- a/app/models/auth.py +++ b/app/models/auth.py @@ -9,8 +9,8 @@ class RegisterRequest(BaseModel): full_name: str | None = Field(None, min_length=2, max_length=100) phone: str | None = None - def resolved_name(self) -> str: - return self.name or self.full_name or "" + def resolved_name(self) -> str | None: + return self.name or self.full_name or None class LoginRequest(BaseModel): diff --git a/app/services/auth_service.py b/app/services/auth_service.py index 851fa93..7b460a1 100644 --- a/app/services/auth_service.py +++ b/app/services/auth_service.py @@ -24,6 +24,7 @@ async def register(req: RegisterRequest, db: asyncpg.Connection) -> dict: "email": req.email, "password": req.password, "email_confirm": True, + "user_metadata": {"full_name": req.resolved_name()}, }) except Exception as e: raise AppError("REGISTRATION_FAILED", str(e), 400) @@ -36,7 +37,10 @@ async def register(req: RegisterRequest, db: asyncpg.Connection) -> dict: """ INSERT INTO profiles (id, email, full_name, phone, role) VALUES ($1, $2, $3, $4, 'client') - ON CONFLICT (id) DO NOTHING + ON CONFLICT (id) DO UPDATE SET + full_name = EXCLUDED.full_name, + email = EXCLUDED.email, + phone = COALESCE(EXCLUDED.phone, profiles.phone) """, user_id, req.email, req.resolved_name(), req.phone, )