Renamed hooks on frontend and started working on shop registration

This commit is contained in:
Thastertyn committed 2025-03-13 15:41:44 +01:00
1 parent 3b42ea6914
commit 9c2b88b103
35 files changed
+180 -37

No files matched your search

+16 -8
View File
@@ -1,24 +1,32 @@
from datetime import timedelta
from typing import Annotated
from fastapi import APIRouter, Depends, HTTPException
from fastapi.security import OAuth2PasswordRequestForm
from fastapi import APIRouter, HTTPException
from app.api.dependencies import SessionDep
from app.api.dependencies import LoginDep, 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
router = APIRouter(tags=["Login"])
router = APIRouter(tags=["Dashboard", "Login"])
@router.post("/login/access-token")
@router.post("/login/access-token", include_in_schema=settings.is_local_environment, response_model=Token)
def login_access_token(
session: SessionDep, form_data: Annotated[OAuth2PasswordRequestForm, Depends()]
session: SessionDep, form_data: LoginDep
) -> Token:
"""
OAuth2 compatible token login, get an access token for future requests
OAuth2 compatible token login for the dashboard.
This endpoint generates an access token required for authenticating future
requests to the dashboard section of the application. The token is valid for
a predefined expiration period.
- **username**: User's email
- **password**: User's password
**Note:** This login is restricted to dashboard access only and cannot be
used for tenant accounts access to shops
"""
user = None
user = user_crud.authenticate(
-2
View File
@@ -1,5 +1,3 @@
from typing import Annotated
from fastapi import APIRouter
from app.api.routes.shop import shop_login_routes, shop_user_routes
Whitespace-only changes.
@@ -9,7 +9,8 @@ from app.database.models.user_model import UserRole
from app.schemas.user_schemas import UserRegister
router = APIRouter(
prefix="/user"
prefix="/user",
tags=["User"]
)
+18
View File
@@ -0,0 +1,18 @@
from fastapi import APIRouter
from app.api.dependencies import CurrentOwnerUser, SessionDep
from app.schemas.shop_schemas import ShopCreate
from app.schemas.user_schemas import Token
router = APIRouter(prefix="/shop", tags=["Shop"])
@router.post("")
def register_new_shop(
session: SessionDep,
current_user: CurrentOwnerUser,
shop_data: ShopCreate
) -> Token:
"""
OAuth2 compatible token login, get an access token for future requests
"""
+8 -2
View File
@@ -1,23 +1,29 @@
import logging
from fastapi import APIRouter
from sqlmodel import select
from fastapi import APIRouter
from app.api.dependencies import SessionDep
from app.core.config import settings
logger = logging.getLogger(__name__)
router = APIRouter(prefix="/utils", tags=["utils"])
router = APIRouter(prefix="/utils", tags=["Utils"])
@router.get("/health-check/")
async def health_check() -> bool:
"""
Ping the API whether it's alive or not
"""
return True
@router.get("/test-db/", include_in_schema=settings.is_local_environment)
async def test_db(session: SessionDep) -> bool:
"""
Ping database using select 1 to see if connection works
"""
try:
session.exec(select(1))
return True