Spaces:
Sleeping
Sleeping
Download src/models/user.py from hashir-qt/keyvault-api: direct link, hf CLI and curl.
- Browser
- Download file 1.07 kB
-
https://huggingface.co/spaces/hashir-qt/keyvault-api/resolve/main/src/models/user.py
- Command line
-
hf download hf://spaces/hashir-qt/keyvault-api/src/models/user.py
-
curl -L -o user.py https://huggingface.co/spaces/hashir-qt/keyvault-api/resolve/main/src/models/user.py
1.07 kB
| import uuid | |
| from datetime import datetime, timezone | |
| from enum import Enum | |
| from typing import Optional | |
| from sqlalchemy import DateTime, Column | |
| from sqlmodel import Field, SQLModel | |
| class UserRole(str, Enum): | |
| """Role assigned to every user. Stored as lowercase strings in the DB.""" | |
| BUYER = "buyer" | |
| SELLER = "seller" | |
| ADMIN = "admin" | |
| class User(SQLModel, table=True): | |
| """Unified user table for buyers, sellers, and admins.""" | |
| __tablename__ = "users" | |
| id: str = Field( | |
| default_factory=lambda: str(uuid.uuid4()), | |
| primary_key=True, | |
| ) | |
| email: str = Field(unique=True, index=True) | |
| username: str = Field(unique=True, index=True) | |
| full_name: str | |
| hashed_password: str | |
| role: UserRole = Field(default=UserRole.BUYER) | |
| is_active: bool = Field(default=True) | |
| is_verified: bool = Field(default=False) | |
| created_at: datetime = Field( | |
| default_factory=lambda: datetime.now(timezone.utc), | |
| sa_column=Column(DateTime(timezone=True), nullable=False), | |
| ) | |