Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class User(Base):

id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
email: Mapped[str] = mapped_column(String(255), unique=True, index=True, nullable=False)
username: Mapped[Optional[str]] = mapped_column(String(50), unique=True, index=True, nullable=True)
full_name: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
phone_number: Mapped[Optional[str]] = mapped_column(String(20), nullable=True)
hashed_password: Mapped[str] = mapped_column(String(255), nullable=False)
role: Mapped[str] = mapped_column(String(50), default="developer", nullable=False)
is_active: Mapped[bool] = mapped_column(Boolean, default=True, nullable=False)
Expand Down
6 changes: 6 additions & 0 deletions app/schemas/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class UserBase(BaseModel):
class UserCreate(UserBase):
"""User creation schema."""
password: str = Field(..., min_length=8, examples=["strong_password_123"])
username: Optional[str] = Field(None, examples=["janesmith"])
full_name: Optional[str] = Field(None, examples=["Jane Smith"])
phone_number: Optional[str] = Field(None, examples=["+1234567890"])



Expand All @@ -40,6 +43,9 @@ class UserLogin(UserBase):
class UserResponse(UserBase):
"""User response schema."""
id: int
username: Optional[str]
full_name: Optional[str]
phone_number: Optional[str]
is_active: bool
is_superuser: bool
created_at: datetime
Expand Down
3 changes: 3 additions & 0 deletions app/services/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ async def create_user(db: AsyncSession, user_in: UserCreate) -> User:
hashed_password = get_password_hash(user_in.password)
db_user = User(
email=user_in.email,
username=user_in.username,
full_name=user_in.full_name,
phone_number=user_in.phone_number,
hashed_password=hashed_password,
)
db.add(db_user)
Expand Down
Loading