Files
bellsystems-cp/backend/users/models.py
T
bonaminandClaude Sonnet 5 0d79a9f72c feat(users): support creating app users with a Firebase Auth account
New users can now be created with a password, which creates a real
Firebase Auth account (so they can log into the mobile app immediately)
alongside the Firestore profile document. UserCreate is now
UserProfile + password (request-only, never persisted or echoed back);
deleting a user also removes their Auth account.

- backend/users: split UserCreate into UserProfile (persisted shape)
  and UserCreate (adds password), wire firebase_auth create/delete
- CreateUserModal: new lightweight modal for creating a user from
  other flows (e.g. device onboarding) without leaving the page
- UserForm: adds the password field for new users; also fixes
  useToast() being used undestructured (toast.success(...) was being
  called on the hook's return value instead of its .toast method)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-21 18:31:37 +03:00

56 lines
1.3 KiB
Python

from pydantic import BaseModel
from typing import List, Optional
# --- Request / Response schemas ---
class UserProfile(BaseModel):
email: str = ""
display_name: str = ""
photo_url: str = ""
uid: str = ""
phone_number: str = ""
status: str = ""
bio: str = ""
userTitle: str = ""
settingsPIN: str = ""
quickSettingsPIN: str = ""
class UserCreate(UserProfile):
password: str = "" # request-only — used to create the Firebase Auth account, never persisted to Firestore or echoed back
class UserUpdate(BaseModel):
email: Optional[str] = None
display_name: Optional[str] = None
photo_url: Optional[str] = None
phone_number: Optional[str] = None
status: Optional[str] = None
bio: Optional[str] = None
userTitle: Optional[str] = None
settingsPIN: Optional[str] = None
quickSettingsPIN: Optional[str] = None
class UserInDB(UserProfile):
id: str
created_time: str = ""
lastActive: str = ""
createdAt: str = ""
friendsList: List[str] = []
friendsInvited: List[str] = []
class UserListResponse(BaseModel):
users: List[UserInDB]
total: int
class SetPasswordRequest(BaseModel):
password: str
class ResetPasswordRequest(BaseModel):
new_password: str = "Bell1234!" # default reset value