feat: added endpoints: auth, pofile, account, keyring #5

Merged
ivan.dev merged 10 commits from VORKOUT-4 into master 2025-05-15 15:21:33 +05:00
2 changed files with 16 additions and 13 deletions
Showing only changes of commit 3554d43d15 - Show all commits

View File

@ -39,6 +39,7 @@ revision:
venv-api:
cd api && \
poetry env activate \
poetry install
install:

View File

@ -26,16 +26,15 @@ api_router = APIRouter(
)
@api_router.get("/{user_id}")
@api_router.get("")
async def get_profile(
ivan.dev marked this conversation as resolved
Review

Тут, наверное, надо переделать
Профиль не должен зависеть от id, то есть, можно переделать роут на просто /profile
Сам пользователя можно брать из загрузки jwt, вроде там уже есть login

Тут, наверное, надо переделать Профиль не должен зависеть от `id`, то есть, можно переделать роут на просто `/profile` Сам пользователя можно брать из загрузки jwt, вроде там уже есть `login`
user_id: int,
request: Request,
connection: AsyncConnection = Depends(get_connection_dep),
):
# Извлекаем текущего пользователя из request.state
current_user = request.state.current_user
user = await get_user_id(connection, user_id)
user = await get_user_login(connection, current_user)
if user is None:
raise HTTPException(
@ -45,9 +44,8 @@ async def get_profile(
return user
@api_router.put("/{user_id}")
@api_router.put("")
async def update_profile(
user_id: int,
request: Request,
ivan.dev marked this conversation as resolved
Review

Тут тоже самое, что и с get_profile, только вот по поводу обновления полей
@cyrussmeat какие поля пользователь не может сам себе обновить? Роль?

Тут тоже самое, что и с `get_profile`, только вот по поводу обновления полей @cyrussmeat какие поля пользователь не может сам себе обновить? Роль?
Review

Роль и Логин

Роль и Логин
user_updata: UserUpdate,
connection: AsyncConnection = Depends(get_connection_dep),
@ -56,20 +54,24 @@ async def update_profile(
current_user = request.state.current_user
user = await get_user_id(connection, user_id)
user = await get_user_login(connection, current_user)
if user is None:
raise HTTPException(
status_code=status.HTTP_404_NOT_FOUND,
detail="Account not found")
if user_updata.role == None and user_updata.login == None:
update_values = update_user_data_changes(user_updata,user)
update_values = update_user_data_changes(user_updata,user)
if update_values is None:
return user
if update_values is None:
return user
await update_user_id(connection, update_values, user)
await update_user_id(connection, update_values, user)
user = await get_user_id(connection, user.id)
user = await get_user_id(connection, user_id)
return user
return user
else:
raise HTTPException(
status_code=status.HTTP_422_UNPROCESSABLE_ENTITY ,
detail="Bad body")