feat/#24 WebOS Completion (#25)

#24 WebOS Completion

Co-authored-by: Sayan Datta <sayan@Sayans-MacBook-Air.local>
Reviewed-on: #25
This commit was merged in pull request #25.
This commit is contained in:
2026-04-18 18:59:04 +05:30
parent 857e0b88e6
commit 84e439712c
459 changed files with 11713 additions and 3853 deletions

View File

@@ -52,9 +52,10 @@ JWT_EXPIRE_HOURS = 8
def create_access_token(user_id: str, role: str) -> str:
expire = datetime.now(timezone.utc) + timedelta(hours=JWT_EXPIRE_HOURS)
normalized_role = role.strip().upper()
payload = {
"sub": user_id,
"role": role,
"role": normalized_role,
"exp": expire,
"iat": datetime.now(timezone.utc),
}
@@ -70,7 +71,7 @@ class UserPrincipal:
@property
def role_level(self) -> int:
return ROLE_HIERARCHY.get(self.role, -1)
return ROLE_HIERARCHY.get(self.role.upper(), -1)
# ── Dependency: parse bearer token ────────────────────────────────────────────
@@ -104,7 +105,7 @@ def get_current_user(
headers={"WWW-Authenticate": "Bearer"},
) from exc
return UserPrincipal(user_id=payload["sub"], role=payload["role"])
return UserPrincipal(user_id=payload["sub"], role=str(payload["role"]).strip().upper())
# ── Dependency factory: role gate ─────────────────────────────────────────────