phase-1: data model, auth, permissions, masters, settings, seed

This commit is contained in:
Atharv1705
2026-11-12 12:28:55 +05:30
parent cb2f48620c
commit e58232a657
48 changed files with 5463 additions and 98 deletions
+12 -5
View File
@@ -1,18 +1,25 @@
from datetime import timedelta
import bcrypt
from jose import JWTError, jwt
from passlib.context import CryptContext
from .config import settings
from .time_utils import utc_now
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
def verify_password(plain: str, hashed: str) -> bool:
return pwd_context.verify(plain, hashed)
if not plain or not hashed:
return False
try:
return bcrypt.checkpw(
plain.encode("utf-8")[:72],
hashed.encode("utf-8"),
)
except ValueError:
return False
def hash_password(plain: str) -> str:
return pwd_context.hash(plain)
hashed = bcrypt.hashpw(plain.encode("utf-8")[:72], bcrypt.gensalt())
return hashed.decode("utf-8")
def create_access_token(data: dict, expires_minutes: int | None = None) -> str: