[rewrite] Implemented login and register

This commit is contained in:
Thastertyn committed 2025-03-12 14:01:13 +01:00
1 parent cd8fdb9c21
commit 20ef2aa4e8
29 files changed
+183 -722

No files matched your search

@@ -1,23 +1,19 @@
from typing import Annotated
from datetime import timedelta
from typing import Annotated
from fastapi import APIRouter, HTTPException, Depends
from fastapi import APIRouter, Depends, HTTPException
from fastapi.security import OAuth2PasswordRequestForm
from app.api.dependencies import SessionDep
from app.core import security
from app.core.config import settings
from app.crud import user_crud
from app.schemas.user_schemas import Token
from app.crud import user_crud
router = APIRouter(prefix="/login", tags=["Login"])
router = APIRouter(tags=["Shop-Login"])
@router.post("/login/access-token")
@router.post("/access-token")
def login_access_token(
session: SessionDep,
form_data: Annotated[OAuth2PasswordRequestForm, Depends()]
Whitespace-only changes.
@@ -3,12 +3,13 @@ from typing import Annotated
from fastapi import APIRouter, Body, Path
from app.api.dependencies import SessionDep
from app.crud.user_crud import create_user
from app.database.models.user_model import UserRole
from app.schemas.user_schemas import UserRegister
router = APIRouter(
prefix="/user",
tags=["Shop-Users"]
prefix="/user"
)
@@ -23,8 +24,8 @@ async def logout():
@router.post("/register", summary="Register new user")
async def register(user_data: UserRegister):
raise NotImplementedError()
async def register(session: SessionDep, user_data: UserRegister, shop_uuid=Annotated[uuid.UUID, Path(title="UUID of the shop")]):
create_user(session, user_data, shop_uuid, UserRole.CUSTOMER)
@router.put("/update", summary="Update user details")