File tree Expand file tree Collapse file tree 6 files changed +19
-23
lines changed Expand file tree Collapse file tree 6 files changed +19
-23
lines changed Original file line number Diff line number Diff line change 1
1
"""
2
- Dependencies
2
+ Dependency annotations
3
3
"""
4
4
5
5
from typing import Annotated
Original file line number Diff line number Diff line change 2
2
Database
3
3
"""
4
4
5
- from sqlalchemy .ext .asyncio import (AsyncEngine , async_sessionmaker ,
6
- create_async_engine )
5
+ from sqlalchemy .ext .asyncio import AsyncEngine , async_sessionmaker , create_async_engine
7
6
from sqlmodel .ext .asyncio .session import AsyncSession
8
7
9
8
from app import repositories as repos
Original file line number Diff line number Diff line change 8
8
from fastapi .security import APIKeyHeader
9
9
10
10
from app .core .db import Database , SessionLocal
11
- from app .core . logic import Logic
11
+ from app .logic import Logic
12
12
from app .core .security import Security
13
13
from app .models .user import User
14
14
@@ -30,7 +30,7 @@ async def get_logic(
30
30
31
31
32
32
async def get_current_user (
33
- token : Annotated [str , Depends (APIKeyHeader (name = ' access-token' ))],
33
+ token : Annotated [str , Depends (APIKeyHeader (name = " access-token" ))],
34
34
logic : Annotated [Logic , Depends (get_logic )],
35
35
) -> User | None :
36
36
return await logic .users .retrieve_by_token (token )
Original file line number Diff line number Diff line change 5
5
from fastapi import HTTPException , status
6
6
7
7
# Users
8
- USER_EXISTS = HTTPException (status .HTTP_409_CONFLICT , ' User is already taken.' )
9
- USER_NOT_FOUND = HTTPException (status .HTTP_404_NOT_FOUND , ' User not found.' )
8
+ USER_EXISTS = HTTPException (status .HTTP_409_CONFLICT , " User is already taken." )
9
+ USER_NOT_FOUND = HTTPException (status .HTTP_404_NOT_FOUND , " User not found." )
10
10
USER_IS_CORRECT = HTTPException (
11
- status .HTTP_401_UNAUTHORIZED , 'User is correct'
12
- )
11
+ status .HTTP_401_UNAUTHORIZED , "User is correct." )
13
12
14
13
# Tokens
15
- TOKEN_INVALID = HTTPException (status .HTTP_401_UNAUTHORIZED , ' Invalid token' )
16
- TOKEN_EXPIRED = HTTPException (status .HTTP_401_UNAUTHORIZED , ' Token expired' )
14
+ TOKEN_INVALID = HTTPException (status .HTTP_401_UNAUTHORIZED , " Invalid token." )
15
+ TOKEN_EXPIRED = HTTPException (status .HTTP_401_UNAUTHORIZED , " Token expired." )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ from app .core .db import Database
2
+ from app .core .security import Security
3
+
1
4
from .users import Users
2
5
3
- __all__ = ['Users' ]
6
+
7
+ class Logic :
8
+ def __init__ (self , db : Database , security : Security ):
9
+ self .users = Users (db , security )
10
+
11
+
12
+ __all__ = ["Logic" ]
You can’t perform that action at this time.
0 commit comments