feat: Update endpoint login

This commit is contained in:
Backend IM Bot 2025-03-19 07:17:32 +00:00
parent fec37cc171
commit c9cf52f576

View File

@ -1,25 +1,50 @@
from fastapi import APIRouter, Depends, HTTPException from fastapi import APIRouter, Depends, HTTPException
from core.auth import get_current_user_dummy
from core.database import fake_users_db from core.database import fake_users_db
import uuid
from typing import List, Optional
router = APIRouter() router = APIRouter()
@router.post("/login") @router.post("/courses")
async def login_demo( async def create_course(
username: str = "demo", title: str,
password: str = "password" description: str,
instructor_id: str,
price: float,
duration_weeks: int,
max_students: Optional[int] = None
): ):
"""Demo login endpoint""" """Create a new course in the online school"""
user = fake_users_db.get(username) course_id = str(uuid.uuid4())
if not user or user["password"] != password:
raise HTTPException(status_code=400, detail="Invalid credentials") if not fake_users_db.get(instructor_id):
raise HTTPException(status_code=400, detail="Instructor not found")
course = {
"id": course_id,
"title": title,
"description": description,
"instructor_id": instructor_id,
"price": price,
"duration_weeks": duration_weeks,
"max_students": max_students,
"enrolled_students": [],
"status": "active"
}
fake_users_db[course_id] = course
return { return {
"message": "Login successful (demo)", "message": "Course created successfully",
"user": username, "course_id": course_id,
"token": "dummy_jwt_token_123", "course_details": course,
"features": { "features": {
"rate_limit": 100, "enrollment_open": True,
"expires_in": 3600 "materials_ready": False
} },
} "next_steps": [
"Upload course materials",
"Set up course schedule",
"Invite students"
]
}