fix: route ordering customer/{id}/health before /{id}; CustomerHealthService for health-overview; keywords/competitor Header decorator; onboarding product_info dict; marketing template fallback; frontend style-switching tabs
This commit is contained in:
@@ -26,6 +26,12 @@ class LoginResponse(BaseModel):
|
||||
user: dict
|
||||
|
||||
|
||||
class LoginRequest(BaseModel):
|
||||
username: str = ""
|
||||
phone: str = ""
|
||||
password: str
|
||||
|
||||
|
||||
class RefreshRequest(BaseModel):
|
||||
refresh_token: str
|
||||
|
||||
@@ -56,17 +62,16 @@ async def register(data: RegisterRequest, db: AsyncSession = Depends(get_db)):
|
||||
|
||||
@router.post("/login", response_model=LoginResponse)
|
||||
async def login(
|
||||
data: dict,
|
||||
data: LoginRequest,
|
||||
db: AsyncSession = Depends(get_db),
|
||||
):
|
||||
phone = data.get("username") or data.get("phone")
|
||||
password = data.get("password")
|
||||
if not phone or not password:
|
||||
raise HTTPException(status_code=422, detail="phone and password required")
|
||||
phone = data.username or data.phone
|
||||
if not phone:
|
||||
raise HTTPException(status_code=422, detail="phone required")
|
||||
result = await db.execute(select(User).where(User.phone == phone))
|
||||
user = result.scalar_one_or_none()
|
||||
|
||||
if not user or not verify_password(password, user.password_hash):
|
||||
if not user or not verify_password(data.password, user.password_hash):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="Invalid credentials",
|
||||
|
||||
Reference in New Issue
Block a user