[rewrite] WIP login and register

This commit is contained in:
Thastertyn committed 2025-03-11 21:53:37 +01:00
1 parent f5547be799
commit cd8fdb9c21
9 files changed
+38 -62

No files matched your search

+9 -3
View File
@@ -1,8 +1,14 @@
from typing import Annotated
from fastapi import APIRouter
from app.api.routes.shop import shop_login_routes, shop_user_routes
api_router = APIRouter()
shop_router = APIRouter(
prefix="/shop/{shop_uuid}",
tags=["Shop"]
)
api_router.include_router(shop_login_routes.router)
api_router.include_router(shop_user_routes.router)
shop_router.include_router(shop_login_routes.router)
shop_router.include_router(shop_user_routes.router)
@@ -3,7 +3,7 @@ from typing import Annotated
from fastapi import APIRouter, Body, Path
from app.schemas.user_schemas import UserRegisterSchema, UserLoginSchema
from app.schemas.user_schemas import UserRegister
router = APIRouter(
@@ -17,18 +17,13 @@ async def delete_user(shop_uuid=Annotated[uuid.UUID, Path(title="UUID of the sho
raise NotImplementedError("delete_user() needs to be implemented.")
@router.post("/login", summary="User login")
async def login(login_data: UserLoginSchema, shop_uuid=Annotated[uuid.UUID, Path(title="UUID of the shop")]):
raise NotImplementedError("login() needs to be implemented.")
@router.delete("/logout", summary="User logout")
async def logout():
raise NotImplementedError("logout() needs to be implemented.")
@router.post("/register", summary="Register new user")
async def register(user_data: UserRegisterSchema):
async def register(user_data: UserRegister):
raise NotImplementedError()
-14
View File
@@ -1,14 +0,0 @@
import uuid
from typing import Annotated
from fastapi import APIRouter, Path
router = APIRouter(
prefix="/shop/{shop_uuid}",
tags=["Shop"]
)
@router.get("/login")
async def get_shop_info(shop_uuid=Annotated[uuid.UUID, Path(title="UUID of the shop")]):
raise NotImplementedError
+6 -21
View File
@@ -1,7 +1,9 @@
from fastapi import APIRouter, Body
from app.schemas.user_schemas import UserRegisterSchema, UserLoginSchema
from app.schemas.user_schemas import UserRegister
from app.api.dependencies import SessionDep
from app.crud import user_crud
router = APIRouter(
prefix="/user",
@@ -14,35 +16,18 @@ async def delete_user():
raise NotImplementedError("delete_user() needs to be implemented.")
@router.post("/login", summary="User login")
async def login(login_data: UserLoginSchema):
raise NotImplementedError("login() needs to be implemented.")
# user = authenticate_user(form_data.username, form_data.password)
# if not user:
# raise HTTPException(
# status_code=status.HTTP_401_UNAUTHORIZED,
# detail="Incorrect username or password",
# headers={"WWW-Authenticate": "Bearer"},
# )
# access_token_expires = timedelta(minutes=30)
# access_token = create_access_token(
# data={"sub": user.username}, expires_delta=access_token_expires
# )
# return Token(access_token=access_token, token_type="bearer")
@router.delete("/logout", summary="User logout")
async def logout():
raise NotImplementedError("logout() needs to be implemented.")
@router.post("/register", summary="Register new user")
async def register(user_data: UserRegisterSchema):
async def register(session: SessionDep, user_data: UserRegister):
try:
create_user(user_data)
user_crud.create_user(session, user_data)
return {"message": "User registered successfully"}
except BaseException:
return {"message": "An error occured"}
return {"message": "An error occurred"}
@router.put("/update", summary="Update user details")