first commit
Some checks failed
Build Docker / build (push) Has been cancelled

This commit is contained in:
2026-02-28 10:47:42 +03:00
commit a763e9c2e0
27 changed files with 556 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import time
from typing import Dict
import jwt as pyjwt
from server.backend.schema.pydantic import settings
def signJWT(user_info: dict) -> str:
payload = {
"user_id": user_info.id,
"admin":user_info.admin,
"expires": time.time() + settings.ACCESS_TOKEN_EXPIRE_SECONDS
}
token = pyjwt.encode(payload, settings.SECRET_KEY, algorithm=settings.ALGORITHM)
return token
def decodeJWT(token: str) -> dict:
try:
decoded_token = pyjwt.decode(token, settings.SECRET_KEY, algorithms=[settings.ALGORITHM])
return decoded_token if decoded_token["expires"] >= time.time() else None
except:
return {}

View File