From 168647f93286ae42922e5ef208b926509341469d Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Tue, 25 Mar 2025 17:14:57 +0000 Subject: [PATCH] Update code in endpoints/login.post.py --- endpoints/login.post.py | 61 ++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 32 deletions(-) diff --git a/endpoints/login.post.py b/endpoints/login.post.py index a8ab4aa..bfb3d1b 100644 --- a/endpoints/login.post.py +++ b/endpoints/login.post.py @@ -1,37 +1,34 @@ -from fastapi import APIRouter, Depends, HTTPException -from pydantic import BaseModel -from datetime import timedelta -from core.database import get_db -from sqlalchemy.orm import Session -from core.auth import verify_password, create_access_token -from models.user import User +from fastapi import APIRouter, HTTPException + +prices = [] # In-memory storage router = APIRouter() -class UserAuth(BaseModel): - username: str - password: str - -@router.post("/login") -async def login( - user_data: UserAuth, - db: Session = Depends(get_db) +@router.post("/petrol-price") +async def update_petrol_price( + price: float = 650.00, + state: str = "Lagos", + station: str = "NNPC" ): - """User authentication endpoint""" - user = db.query(User).filter(User.username == user_data.username).first() - - if not user or not verify_password(user_data.password, user.hashed_password): - raise HTTPException(status_code=400, detail="Invalid credentials") - - # Generate token with expiration - access_token = create_access_token( - data={"sub": user.id}, - expires_delta=timedelta(hours=1) - ) - + """Update petrol price endpoint""" + if price <= 0: + raise HTTPException(status_code=400, detail="Invalid price amount") + + prices.append({ + "price_per_litre": price, + "state": state, + "station": station, + "currency": "NGN", + "last_updated": "2024-01-19" + }) + return { - "access_token": access_token, - "token_type": "bearer", - "user_id": user.id, - "username": user.username - } + "message": "Price updated successfully", + "price": price, + "state": state, + "station": station, + "features": { + "rate_limit": 100, + "expires_in": 3600 + } + } \ No newline at end of file