User Log and Persistent Faction Information
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
"""Utility functions package."""
|
||||
#Utility functions package
|
||||
from .file_helpers import load_json_list, sync_state_from_file
|
||||
|
||||
__all__ = ["load_json_list", "sync_state_from_file"]
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,11 +1,11 @@
|
||||
"""Authentication utilities and dependencies."""
|
||||
#Authentication utilities and dependencies
|
||||
import jwt
|
||||
from fastapi import Request, HTTPException
|
||||
import config as config_module
|
||||
|
||||
|
||||
def get_current_user(request: Request) -> dict:
|
||||
"""Dependency to check authentication and return user info"""
|
||||
#Dependency to check authentication and return user info
|
||||
token = request.cookies.get("auth_token")
|
||||
|
||||
if not token:
|
||||
@@ -21,7 +21,7 @@ def get_current_user(request: Request) -> dict:
|
||||
|
||||
|
||||
def check_auth(request: Request) -> bool:
|
||||
"""Check if user is authenticated (returns bool, doesn't raise exception)"""
|
||||
#Check if user is authenticated (returns bool, doesn't raise exception)
|
||||
token = request.cookies.get("auth_token")
|
||||
if not token:
|
||||
return False
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"""File I/O helper utilities."""
|
||||
#File I/O helper utilities
|
||||
import json
|
||||
from pathlib import Path
|
||||
from services.server_state import STATE
|
||||
|
||||
|
||||
def load_json_list(path: Path):
|
||||
"""Load a JSON file and return it as a list."""
|
||||
#Load a JSON file and return it as a list
|
||||
if not path.exists():
|
||||
return []
|
||||
with open(path, "r", encoding="utf-8") as f:
|
||||
@@ -13,10 +13,8 @@ def load_json_list(path: Path):
|
||||
|
||||
|
||||
async def sync_state_from_file(path: Path, kind: str):
|
||||
"""
|
||||
Read JSON file (list of members dicts) and upsert into STATE.
|
||||
Expected member dict keys: id, name, level, estimate, optionally status/hits.
|
||||
"""
|
||||
#Read JSON file (list of members dicts) and upsert into STATE.
|
||||
#Expected member dict keys: id, name, level, estimate, optionally status/hits.
|
||||
arr = load_json_list(path)
|
||||
received_ids = []
|
||||
for m in arr:
|
||||
|
||||
Reference in New Issue
Block a user