|
1 | 1 | from fastapi import APIRouter |
2 | 2 |
|
3 | 3 | from app.api import anotations |
4 | | -from app.core import deps, exps |
| 4 | +from app.core import exps |
5 | 5 | from app.models.token import AccessToken |
6 | 6 | from app.models.user import UserCreate |
7 | 7 |
|
8 | | -router = APIRouter(prefix="/auth") |
| 8 | +router = APIRouter(prefix='/auth') |
9 | 9 |
|
10 | 10 |
|
11 | | -@router.post("/token/", response_model=AccessToken) |
| 11 | +@router.post('/token/', response_model=AccessToken) |
12 | 12 | async def token( |
13 | 13 | data: UserCreate, db: anotations.Database, security: anotations.Security |
14 | 14 | ): |
15 | 15 | """ |
16 | 16 | Retrieve new access token |
17 | 17 | """ |
18 | 18 | if user := await db.user.retrieve_by_email(data.email): |
19 | | - if not deps.pwd_context.verify(data.password, user.password): |
| 19 | + if not security.pwd.checkpwd(data.password, user.password): |
20 | 20 | raise exps.USER_IS_CORRECT |
21 | | - access_token = security.jwt.encode_token({"id": user.id}, 1440) |
| 21 | + access_token = security.jwt.encode_token({'id': user.id}, 1440) |
22 | 22 | return AccessToken(token=access_token) |
23 | 23 |
|
24 | 24 | raise exps.USER_NOT_FOUND |
0 commit comments