feat: Update endpoint login
This commit is contained in:
parent
b92e35db55
commit
8342b27dd1
@ -1,7 +1,29 @@
|
||||
from fastapi import APIRouter
|
||||
from fastapi import APIRouter, Depends, File, UploadFile
|
||||
from sqlalchemy.orm import Session
|
||||
from typing import List
|
||||
|
||||
from app.db import get_db
|
||||
from app.models import User
|
||||
from app.schemas import UserProfile, UserProfileResponse
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
@router.post("/login")
|
||||
async def login(username: str, password: str):
|
||||
return {"message": "User logged in successfully", "username": username}
|
||||
@router.post("/profile", response_model=UserProfileResponse)
|
||||
async def upload_profile(
|
||||
files: List[UploadFile] = File(...),
|
||||
user: User = Depends(get_current_user),
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
"""
|
||||
Upload user profile picture(s)
|
||||
"""
|
||||
profile_pics = []
|
||||
for file in files:
|
||||
contents = await file.read()
|
||||
profile_pic = UserProfile(name=file.filename, data=contents, user_id=user.id)
|
||||
db.add(profile_pic)
|
||||
db.commit()
|
||||
db.refresh(profile_pic)
|
||||
profile_pics.append(profile_pic)
|
||||
|
||||
return {"profile_pics": profile_pics, "message": "Profile picture(s) uploaded successfully"}
|
Loading…
x
Reference in New Issue
Block a user