add some in company and linters

This commit is contained in:
2024-04-08 23:55:30 +03:00
parent efdacfa0ce
commit 361378929f
13 changed files with 87 additions and 36 deletions

View File

@@ -12,9 +12,7 @@ from api.infrastructure.auth.jwt_settings import JwtSettings
class JoseJwtTokenProcessor(JwtTokenProcessor):
def __init__(
self, jwt_options: JwtSettings, date_time_provider: DateTimeProvider
) -> None:
def __init__(self, jwt_options: JwtSettings, date_time_provider: DateTimeProvider) -> None:
self.jwt_options = jwt_options
self.date_time_provider = date_time_provider
@@ -32,9 +30,7 @@ class JoseJwtTokenProcessor(JwtTokenProcessor):
def validate_token(self, token: str) -> UserId | None:
try:
payload = decode(
token, self.jwt_options.secret, [self.jwt_options.algorithm]
)
payload = decode(token, self.jwt_options.secret, [self.jwt_options.algorithm])
return UserId(UUID(payload["sub"]))
except (JWTError, ValueError, KeyError):
return None

View File

@@ -2,4 +2,4 @@ from sqlalchemy.orm import DeclarativeBase
class Base(DeclarativeBase):
...
pass

View File

@@ -0,0 +1,45 @@
# from sqlalchemy import text
# from sqlalchemy.ext.asyncio import AsyncSession
#
# from api.domain.company import CompanyRepository, company
# from api.domain.user.model import UserEmail, UserFirstName, UserId
#
#
# class SqlAlchemyUserRepository(UserRepository):
# def __init__(self, session: AsyncSession) -> None:
# self.session = session
#
# async def create_user(self, user: User) -> None:
# stmt = text(
# """INSERT INTO users (id, name, email, hashed_password)
# VALUES(:id, :name, :email, :hashed_password)
# """
# )
# await self.session.execute(
# stmt,
# {
# "id": str(user.id.value),
# "name": user.name.value,
# "email": user.email.value,
# "hashed_password": user.hashed_password,
# },
# )
#
# async def get_user(self, filter: dict) -> User | None:
# stmt = text("""SELECT * FROM users WHERE email = :val""")
# result = await self.session.execute(stmt, {"val": filter["email"]})
#
# result = result.mappings().one_or_none()
#
# if result is None:
# return None
#
# return User(
# id=UserId(result.id),
# name=UserFirstName(result.name),
# email=UserEmail(result.email),
# hashed_password=result.hashed_password,
# )
#
# async def get_users(self) -> list[User]:
# return []