Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bck 44/del role in resp reg user #86

Merged
merged 3 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/api/endpoints/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from app.core.db import get_async_session
from app.core.user import auth_backend, fastapi_users
from app.crud.user import user_crud
from app.schemas.user import UserCreate, UserRead, UserUpdate
from app.schemas.user import UserCreate, UserRead, UserReadRegister, UserUpdate
from app.services.token_generator.tokens import token_generator

router = APIRouter()
Expand All @@ -24,7 +24,7 @@

router.include_router(
register.get_register_router(
UserRead,
UserReadRegister,
Annotated[UserCreate, Body(example=USER_VALUE)]
),
prefix='/auth',
Expand Down
1 change: 0 additions & 1 deletion app/api_docs_responses/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
'is_active': True,
'is_superuser': True,
'is_verified': False,
'role': 'user',
'username': 'Имя',
'tariff_id': 0
}
Expand Down
2 changes: 1 addition & 1 deletion app/core/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async def on_after_register(
'Welcome to QActf.',
f'{URL}/auth/confirm/{user_uid}/{user_code}',
)
await cofirm_email.send_email_message()
# await cofirm_email.send_email_message()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Закомментированный код необходимо удалять :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

принял. действительно)



async def get_user_manager(user_db=Depends(get_user_db)):
Expand Down
2 changes: 1 addition & 1 deletion app/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ asyncpg==0.29.0
attrs==23.1.0
Babel==2.14.0
backcall==0.2.0
bcrypt==4.1.1
bcrypt==4.0.1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему мы здесь понижаем версию библиотеки?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

При сборке контейнеров возникала ошибка: AttributeError: module 'bcrypt' has no attribute 'about'
Не понял влияло ли это на работоспособность, просто мозолила глаза. Наткнулся на обсуждение подобной проблемы.

black==23.12.0
certifi==2023.11.17
cffi==1.16.0
Expand Down
13 changes: 8 additions & 5 deletions app/schemas/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@
from app.core.constants import Role


class UserRead(schemas.BaseUser[int]):
role: Annotated[
Choice,
WithJsonSchema({'type': 'str'})
]
class UserReadRegister(schemas.BaseUser[int]):
username: str
tariff_id: Optional[int]

class Config:
from_attributes = True
arbitrary_types_allowed = True


class UserRead(UserReadRegister):
role: Annotated[
Choice,
WithJsonSchema({'type': 'str'})
]

@field_serializer('role')
def serialize_role(self, role: Choice, _info):
return role.code
Expand Down