Updates the user registration and new account creation endpoints to require email confirmation. - Sets the 'confirmed' flag to 'false' by default for all new user accounts. - Generates a unique confirmation token for each new user. - Logs the confirmation link to the console for development purposes. This change ensures that users cannot log in without first verifying their email address, enhancing account security.
27 lines
1009 B
Python
27 lines
1009 B
Python
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
from sqlalchemy import select
|
|
from database import get_db
|
|
from models import Pricing_Oil_Oil
|
|
|
|
router = APIRouter()
|
|
|
|
@router.get("/current")
|
|
async def get_current_pricing(db: AsyncSession = Depends(get_db)):
|
|
# Get the latest pricing record
|
|
pricing = await db.execute(
|
|
select(Pricing_Oil_Oil).order_by(Pricing_Oil_Oil.id.desc()).limit(1)
|
|
)
|
|
pricing = pricing.scalar_one_or_none()
|
|
|
|
if not pricing:
|
|
return {"price_per_gallon": 0.00, "message": "No pricing available"}
|
|
|
|
return {
|
|
"price_per_gallon": float(pricing.price_for_customer),
|
|
"price_same_day": float(pricing.price_same_day) if pricing.price_same_day else 0.00,
|
|
"price_prime": float(pricing.price_prime) if pricing.price_prime else 0.00,
|
|
"price_emergency": float(pricing.price_emergency) if pricing.price_emergency else 0.00,
|
|
"date": pricing.date.isoformat() if pricing.date else None
|
|
}
|