- Implemented endpoints for forgot password and reset password - Added PasswordResetToken model and relationships - Integrated email service using Resend for sending reset links - Updated configuration for email and frontend URL - Enhanced user model to include password reset tokens - Added necessary schemas for password reset requests - Updated requirements to include Resend SDK - Created comprehensive documentation for the new feature
27 lines
1.2 KiB
Python
27 lines
1.2 KiB
Python
import uuid
|
|
from datetime import datetime
|
|
|
|
from sqlalchemy import DateTime, String
|
|
from sqlalchemy.dialects.mysql import CHAR
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class User(Base):
|
|
__tablename__ = "users"
|
|
|
|
id: Mapped[str] = mapped_column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
|
email: Mapped[str] = mapped_column(String(100), unique=True)
|
|
username: Mapped[str] = mapped_column(String(20), unique=True)
|
|
password: Mapped[str] = mapped_column(String(255))
|
|
email_verified_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
|
tenant_id: Mapped[str | None] = mapped_column(CHAR(36), nullable=True)
|
|
status: Mapped[str] = mapped_column(String(20), default="INACTIVE")
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.now)
|
|
updated_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True, onupdate=datetime.now)
|
|
deleted_at: Mapped[datetime | None] = mapped_column(DateTime, nullable=True)
|
|
|
|
profile: Mapped["UserProfile"] = relationship(back_populates="user", uselist=False)
|
|
password_reset_tokens: Mapped[list["PasswordResetToken"]] = relationship(back_populates="user")
|