diff --git a/endpoints/auth.get.py b/endpoints/auth.get.py index 6d3adaa..f995809 100644 --- a/endpoints/auth.get.py +++ b/endpoints/auth.get.py @@ -1,19 +1,28 @@ from fastapi import APIRouter, HTTPException -users = [] # In-memory storage +users = [ + { + "username": "admin", + "password": "securepassword" + } +] router = APIRouter() @router.get("/auth") -async def authenticate_user(): +async def authenticate_user( + username: str = "admin", + password: str = "securepassword" +): """authenticates the user""" + user = next((u for u in users if u["username"] == username), None) + if not user or user["password"] != password: + raise HTTPException(status_code=400, detail="Invalid credentials") + return { "method": "GET", - "_verb": "get" - } - -``` - -This code defines a GET endpoint at `/auth` using FastAPI's `APIRouter`. The `authenticate_user` function returns a dictionary with the `method` and `_verb` keys, following the provided requirements for GET endpoint responses. - -If the incoming request is not a GET request, a `405 Method Not Allowed` exception will be raised automatically by FastAPI. \ No newline at end of file + "_verb": "get", + "message": "Authentication successful", + "user": username, + "token": "dummy_jwt_token_456" + } \ No newline at end of file