Spaces:
Sleeping
Sleeping
Commit
·
0b396f5
1
Parent(s):
284bb72
1.0.3 debug
Browse files
main.py
CHANGED
|
@@ -10,14 +10,11 @@ from user_agents import parse
|
|
| 10 |
from dotenv import load_dotenv
|
| 11 |
from supabase import create_client, Client
|
| 12 |
from typing import Optional
|
| 13 |
-
import logging
|
| 14 |
-
from time import sleep
|
| 15 |
-
import asyncio
|
| 16 |
|
| 17 |
load_dotenv()
|
| 18 |
|
| 19 |
SERVER_NAME = "Nexus Authentication Service"
|
| 20 |
-
VERSION = "1.0.
|
| 21 |
|
| 22 |
# Supabase Configuration
|
| 23 |
SUPABASE_URL = os.getenv("SUPABASE_URL")
|
|
@@ -91,19 +88,6 @@ def is_token_expired(expiration_time: datetime) -> bool:
|
|
| 91 |
return datetime.now(timezone.utc) > expiration_time
|
| 92 |
|
| 93 |
|
| 94 |
-
logging.basicConfig(level=logging.INFO)
|
| 95 |
-
|
| 96 |
-
async def clean_expired_tokens():
|
| 97 |
-
while True:
|
| 98 |
-
current_time = datetime.now(timezone.utc)
|
| 99 |
-
try:
|
| 100 |
-
supabase.table("sessions").delete().lt("expires", current_time.isoformat()).execute()
|
| 101 |
-
logging.info(f"Expired tokens cleaned at {current_time.isoformat()}")
|
| 102 |
-
except Exception as e:
|
| 103 |
-
logging.error(f"Failed to clean expired tokens: {e}")
|
| 104 |
-
await sleep(6 * 60 * 60)
|
| 105 |
-
|
| 106 |
-
|
| 107 |
# Initialize system user
|
| 108 |
async def init_system_user():
|
| 109 |
system_user_data = {
|
|
@@ -415,5 +399,4 @@ app.include_router(admin_router)
|
|
| 415 |
# Initialize system user on startup
|
| 416 |
@app.on_event("startup")
|
| 417 |
async def startup_event():
|
| 418 |
-
await init_system_user()
|
| 419 |
-
await asyncio.create_task(clean_expired_tokens())
|
|
|
|
| 10 |
from dotenv import load_dotenv
|
| 11 |
from supabase import create_client, Client
|
| 12 |
from typing import Optional
|
|
|
|
|
|
|
|
|
|
| 13 |
|
| 14 |
load_dotenv()
|
| 15 |
|
| 16 |
SERVER_NAME = "Nexus Authentication Service"
|
| 17 |
+
VERSION = "1.0.3 debug"
|
| 18 |
|
| 19 |
# Supabase Configuration
|
| 20 |
SUPABASE_URL = os.getenv("SUPABASE_URL")
|
|
|
|
| 88 |
return datetime.now(timezone.utc) > expiration_time
|
| 89 |
|
| 90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 91 |
# Initialize system user
|
| 92 |
async def init_system_user():
|
| 93 |
system_user_data = {
|
|
|
|
| 399 |
# Initialize system user on startup
|
| 400 |
@app.on_event("startup")
|
| 401 |
async def startup_event():
|
| 402 |
+
await init_system_user()
|
|
|