From 9b686d79871c6f76b8ea36d8a8a43d3edb32def7 Mon Sep 17 00:00:00 2001 From: Botond Hende Date: Fri, 30 Aug 2024 22:28:58 +0200 Subject: agents are authenticated on space traders api --- __main__.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to '__main__.py') diff --git a/__main__.py b/__main__.py index 9dba645..9b23484 100644 --- a/__main__.py +++ b/__main__.py @@ -4,13 +4,15 @@ from typing import Annotated from fastapi import FastAPI, Depends from .apirouters import agents -from .modules import database +from .modules.database import cursor, conn @asynccontextmanager async def lifespan(app: FastAPI): - database.cursor.execute( - "CREATE TABLE IF NOT EXISTS agents(primary_key INTEGER PRIMARY KEY, callsign TEXT NOT NULL UNIQUE, token_hash TEXT NOT NULL)") + cursor.execute( + "CREATE TABLE IF NOT EXISTS agents(primary_key INTEGER PRIMARY KEY, callsign TEXT NOT NULL UNIQUE, token TEXT NOT NULL)") + conn.commit() + agents.load_agents_from_database() yield -- cgit v1.2.3-70-g09d2