add OAuth2PasswordRequestForm
This commit is contained in:
14
poetry.lock
generated
14
poetry.lock
generated
@@ -590,6 +590,18 @@ files = [
|
||||
[package.extras]
|
||||
cli = ["click (>=5.0)"]
|
||||
|
||||
[[package]]
|
||||
name = "python-multipart"
|
||||
version = "0.0.20"
|
||||
description = "A streaming multipart parser for Python"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "python_multipart-0.0.20-py3-none-any.whl", hash = "sha256:8a62d3a8335e06589fe01f2a3e178cdcc632f3fbe0d492ad9ee0ec35aab1f104"},
|
||||
{file = "python_multipart-0.0.20.tar.gz", hash = "sha256:8dd0cab45b8e23064ae09147625994d090fa46f5b0d1e13af944c331a7fa9d13"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ruff"
|
||||
version = "0.11.12"
|
||||
@@ -793,4 +805,4 @@ standard = ["colorama (>=0.4) ; sys_platform == \"win32\"", "httptools (>=0.6.3)
|
||||
[metadata]
|
||||
lock-version = "2.1"
|
||||
python-versions = ">=3.12"
|
||||
content-hash = "bddd2102f9e1901ece4bcffde03bc1512cf4319a897a0f14444236d5e0cb8401"
|
||||
content-hash = "7f9ca5ce7505707747e59087ccbb804dc0fef135c963fd2d2ebc8c91285ec188"
|
||||
|
||||
@@ -23,6 +23,7 @@ dependencies = [
|
||||
"passlib (>=1.7.4,<2.0.0)",
|
||||
"email-validator (>=2.2.0,<3.0.0)",
|
||||
"bcrypt (==4.0.1)",
|
||||
"python-multipart (>=0.0.20,<0.0.21)",
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
from fastapi import APIRouter
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
from fastapi.security import OAuth2PasswordRequestForm
|
||||
|
||||
from src.api.dependacies.db_dep import sessionDep
|
||||
from src.schemas.users import UserRequestADD, UserRequest
|
||||
from src.schemas.users import UserRequestADD
|
||||
from src.core.settings import settings
|
||||
from src.services.auth import AuthService
|
||||
|
||||
@@ -15,6 +18,8 @@ async def registration(session: sessionDep, credential: UserRequestADD):
|
||||
|
||||
|
||||
@router.post(path="/login")
|
||||
async def login(session: sessionDep, credential: UserRequest):
|
||||
|
||||
...
|
||||
async def login(
|
||||
session: sessionDep,
|
||||
credential: Annotated[OAuth2PasswordRequestForm, Depends()],
|
||||
):
|
||||
user = AuthService(session).login(credential.username, credential.password)
|
||||
|
||||
@@ -14,6 +14,8 @@ class AuthService(BaseService):
|
||||
is_superuser=False,
|
||||
)
|
||||
result = await self.session.user.create_one(user_to_insert)
|
||||
print(result)
|
||||
await self.session.commit()
|
||||
return User.model_validate(result)
|
||||
|
||||
async def login(self, username: str, password: str):
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user