added burger menu with admin page and user invitation link generation
This commit is contained in:
@@ -17,3 +17,20 @@ class LoginResponse(BaseModel):
|
||||
username: str
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
|
||||
|
||||
class RegisterRequest(BaseModel):
|
||||
"""Request model for user registration."""
|
||||
|
||||
username: str
|
||||
password: str
|
||||
invitation_token: str
|
||||
|
||||
|
||||
class RegisterResponse(BaseModel):
|
||||
"""Response model for successful registration."""
|
||||
|
||||
message: str
|
||||
username: str
|
||||
access_token: str
|
||||
token_type: str = "bearer"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Database models."""
|
||||
|
||||
from sqlalchemy import Column, Integer, String, DateTime
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Boolean
|
||||
from datetime import datetime
|
||||
|
||||
from baby_monitor.repositories.dependencies.get_database import Base
|
||||
@@ -14,6 +14,7 @@ class User(Base):
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
username = Column(String, unique=True, index=True, nullable=False)
|
||||
hashed_password = Column(String, nullable=False)
|
||||
is_admin = Column(Boolean, default=False, nullable=False)
|
||||
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Invitation token model for user registration.
|
||||
|
||||
Note: DateTime(timezone=True) is used for PostgreSQL compatibility.
|
||||
SQLite will store as naive UTC, which is handled in the repository layer.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Boolean, DateTime, Integer, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from baby_monitor.repositories.dependencies.get_database import Base
|
||||
|
||||
|
||||
class Invitation(Base):
|
||||
"""Invitation token for new user registration."""
|
||||
|
||||
__tablename__ = "invitations"
|
||||
|
||||
id: Mapped[int] = mapped_column(
|
||||
Integer, primary_key=True, autoincrement=True
|
||||
)
|
||||
token: Mapped[str] = mapped_column(String, unique=True, nullable=False)
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), nullable=False
|
||||
)
|
||||
expires_at: Mapped[datetime] = mapped_column(
|
||||
DateTime(timezone=True), nullable=False
|
||||
)
|
||||
created_by_user_id: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
is_consumed: Mapped[bool] = mapped_column(
|
||||
Boolean, default=False, nullable=False
|
||||
)
|
||||
consumed_at: Mapped[datetime | None] = mapped_column(
|
||||
DateTime(timezone=True), nullable=True
|
||||
)
|
||||
Reference in New Issue
Block a user