mirror of
http://88.130.71.182:3000/BlitTech/badoHair_be.git
synced 2026-06-12 23:23:22 +00:00
Fixed issues after second dev test
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user