API key check implemented

This commit is contained in:
Profitroll 2023-01-17 10:54:23 +01:00
parent 94095288b7
commit 0476167823

View File

@ -27,4 +27,8 @@ async def apikey_put(apikey: APIKey = Depends(get_api_key)):
if path.exists(path.join(configGet("data", "locations"), apikey)): # type: ignore if path.exists(path.join(configGet("data", "locations"), apikey)): # type: ignore
move(path.join(configGet("data", "locations"), apikey), path.join(configGet("data", "locations"), new_key)) # type: ignore move(path.join(configGet("data", "locations"), apikey), path.join(configGet("data", "locations"), new_key)) # type: ignore
return UJSONResponse({"apikey": new_key}) return UJSONResponse({"apikey": new_key})
@app.get("/apikey", response_class=UJSONResponse, description="Check API key")
async def apikey_check(apikey: APIKey = Depends(get_api_key)):
return UJSONResponse({"detail": "This key is valid."})