Team Ai
Apppublic

kernelmind/Resume-Screener-API

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
models.py40 linesDownload Raw Back to auth
1"""2User model for authentication.3 4Simple user table with email and hashed password.5Using passlib for secure password hashing.6"""7 8from datetime import datetime, timezone9 10from passlib.context import CryptContext11from sqlalchemy import Column, Integer, String, DateTime12 13from src.database import Base14 15 16# Password hashing context - pbkdf2_sha256 has no password length limit17# and is NIST-approved, secure, and works out of the box18pwd_context = CryptContext(schemes=["pbkdf2_sha256"], deprecated="auto")19 20 21class User(Base):22    """User model for authentication."""23    24    __tablename__ = "users"25    26    id = Column(Integer, primary_key=True, index=True)27    email = Column(String, unique=True, index=True, nullable=False)28    hashed_password = Column(String, nullable=False)29    created_at = Column(DateTime, default=lambda: datetime.now(timezone.utc))30    31    def verify_password(self, plain_password: str) -> bool:32        """Check if provided password matches the hash."""33        return pwd_context.verify(plain_password, self.hashed_password)34    35    @staticmethod36    def hash_password(plain_password: str) -> str:37        """Hash a password for storage."""38        return pwd_context.hash(plain_password)39 40