Update code in endpoints/login.post.py
This commit is contained in:
parent
3248c0ca14
commit
0c260c6250
@ -1,16 +1,15 @@
|
|||||||
from fastapi import APIRouter, HTTPException
|
from fastapi import APIRouter, HTTPException
|
||||||
import uuid
|
|
||||||
|
|
||||||
users = [] # In-memory storage
|
users = [] # In-memory storage
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.post("/login")
|
@router.post("/login")
|
||||||
async def login_user(
|
async def login_user(
|
||||||
username: str = "new_user",
|
username: str = "user",
|
||||||
password: str = "securepassword123"
|
password: str = "password"
|
||||||
):
|
):
|
||||||
"""User login endpoint"""
|
"""Blog user login endpoint"""
|
||||||
user = next((u for u in users if u["username"] == username), None)
|
user = next((u for u in users if u["username"] == username), None)
|
||||||
if not user or user["password"] != password:
|
if not user or user["password"] != password:
|
||||||
raise HTTPException(status_code=400, detail="Invalid credentials")
|
raise HTTPException(status_code=400, detail="Invalid credentials")
|
||||||
@ -18,7 +17,7 @@ async def login_user(
|
|||||||
return {
|
return {
|
||||||
"message": "Login successful",
|
"message": "Login successful",
|
||||||
"user": username,
|
"user": username,
|
||||||
"token": "jwt_token_" + str(uuid.uuid4()),
|
"token": "blog_jwt_token_123",
|
||||||
"features": {
|
"features": {
|
||||||
"rate_limit": 100,
|
"rate_limit": 100,
|
||||||
"expires_in": 3600
|
"expires_in": 3600
|
||||||
|
Loading…
x
Reference in New Issue
Block a user