Remove token revocation logic and unused dependencies
Eliminated the `RevokedToken` model and associated logic for managing token revocation. Removed unused files, related tests, and outdated dependencies in authentication modules. Simplified token decoding, user validation, and dependency injection by streamlining the flow and enhancing maintainability.
This commit is contained in:
@@ -1,15 +1,12 @@
|
||||
import logging
|
||||
|
||||
from apscheduler.schedulers.asyncio import AsyncIOScheduler
|
||||
from apscheduler.triggers.cron import CronTrigger
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.responses import HTMLResponse
|
||||
|
||||
from app.core.config import settings
|
||||
from app.api.main import api_router
|
||||
import logging
|
||||
|
||||
from auth.utils import cleanup_expired_tokens
|
||||
from app.core.database import SessionLocal
|
||||
from app.core.config import settings
|
||||
|
||||
scheduler = AsyncIOScheduler()
|
||||
|
||||
@@ -32,26 +29,6 @@ app.add_middleware(
|
||||
)
|
||||
|
||||
|
||||
# Create a function that gets its own database session
|
||||
async def scheduled_cleanup():
|
||||
async with SessionLocal() as db:
|
||||
await cleanup_expired_tokens(db)
|
||||
|
||||
@app.on_event("startup")
|
||||
async def start_scheduler():
|
||||
# Run every day at 3 AM
|
||||
scheduler.add_job(
|
||||
scheduled_cleanup,
|
||||
CronTrigger(hour=10, minute=0),
|
||||
id="token_cleanup",
|
||||
name="Clean up expired revoked tokens"
|
||||
)
|
||||
scheduler.start()
|
||||
|
||||
@app.on_event("shutdown")
|
||||
async def stop_scheduler():
|
||||
scheduler.shutdown()
|
||||
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
async def root():
|
||||
return """
|
||||
@@ -67,4 +44,5 @@ async def root():
|
||||
</html>
|
||||
"""
|
||||
|
||||
app.include_router(api_router, prefix=settings.API_V1_STR)
|
||||
|
||||
app.include_router(api_router, prefix=settings.API_V1_STR)
|
||||
|
||||
Reference in New Issue
Block a user