Renamed hooks on frontend and started working on shop registration
This commit is contained in:
1 parent
3b42ea6914
commit
9c2b88b103
35 files changed
+180
-37
No files matched your search
@@ -1,6 +1,6 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.api.routes import cart_routes, login_routes, shop, user_routes, utils_routes
|
||||
from app.api.routes import cart_routes, login_routes, shop, user_routes, utils_routes, shop_routes
|
||||
|
||||
api_router = APIRouter()
|
||||
|
||||
@@ -9,3 +9,4 @@ api_router.include_router(user_routes.router)
|
||||
api_router.include_router(utils_routes.router)
|
||||
api_router.include_router(login_routes.router)
|
||||
api_router.include_router(shop.shop_router)
|
||||
api_router.include_router(shop_routes.router)
|
||||
@@ -2,7 +2,7 @@ from typing import Annotated
|
||||
|
||||
import jwt
|
||||
from fastapi import Depends, HTTPException, status
|
||||
from fastapi.security import OAuth2PasswordBearer
|
||||
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
|
||||
from jwt.exceptions import InvalidTokenError
|
||||
from pydantic import ValidationError
|
||||
from sqlmodel import Session
|
||||
@@ -19,6 +19,7 @@ reusable_oauth2 = OAuth2PasswordBearer(
|
||||
|
||||
SessionDep = Annotated[Session, Depends(get_session)]
|
||||
TokenDep = Annotated[str, Depends(reusable_oauth2)]
|
||||
LoginDep = Annotated[OAuth2PasswordRequestForm, Depends()]
|
||||
|
||||
|
||||
def get_current_user(session: SessionDep, token: TokenDep) -> User:
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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"]
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
"""
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user