feat(account): GET /me user endpoint only, disable cache and extra routers

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-12 20:44:35 +03:00
commit d94dd31439
107 changed files with 5083 additions and 0 deletions

View File

@@ -0,0 +1,150 @@
from fastapi import APIRouter, Request, Depends
from fastapi.responses import ORJSONResponse
from starlette import status
from src.application.commands import SetPhoneCommand, SetCryptoWalletStartCommand, SetCryptoWalletCompleteCommand, UpdateBankDetailsStartCommand, UpdateBankDetailsCompleteCommand, ChangePasswordStartCommand, ChangePasswordCompleteCommand, ChangeEmailStartCommand, ChangeEmailConfirmOldCommand, ChangeEmailCompleteCommand
from src.application.domain.dto import AuthContext
from src.presentation.decorators import require_access_token
from src.presentation.dependencies import (
get_set_phone_command,
get_set_crypto_wallet_start_command,
get_set_crypto_wallet_complete_command,
get_update_bank_details_start_command,
get_update_bank_details_complete_command,
get_change_password_start_command,
get_change_password_complete_command,
get_change_email_start_command,
get_change_email_confirm_old_command,
get_change_email_complete_command,
)
from src.presentation.schemas import SetPhoneRequest, CryptoWalletConfirmRequest, BankConfirmRequest, ChangePasswordConfirmRequest, ChangeEmailConfirmOldRequest, ChangeEmailCompleteRequest
account_settings_router = APIRouter(prefix='/settings')
@account_settings_router.patch(path='/phone', response_class=ORJSONResponse, status_code=status.HTTP_200_OK)
async def set_phone(
request: Request,
body: SetPhoneRequest,
auth: AuthContext = Depends(require_access_token),
command: SetPhoneCommand = Depends(get_set_phone_command),
):
user = await command(user_id=auth.user_id, phone=body.phone)
return ORJSONResponse(status_code=status.HTTP_200_OK, content={'phone': user.phone})
@account_settings_router.post(path='/crypto-wallet/start', response_class=ORJSONResponse, status_code=status.HTTP_200_OK)
async def crypto_wallet_start(
request: Request,
auth: AuthContext = Depends(require_access_token),
command: SetCryptoWalletStartCommand = Depends(get_set_crypto_wallet_start_command),
):
result = await command(user_id=auth.user_id)
return {'success': result}
@account_settings_router.post(path='/crypto-wallet/complete', response_class=ORJSONResponse, status_code=status.HTTP_200_OK)
async def crypto_wallet_complete(
request: Request,
body: CryptoWalletConfirmRequest,
auth: AuthContext = Depends(require_access_token),
command: SetCryptoWalletCompleteCommand = Depends(get_set_crypto_wallet_complete_command),
):
user = await command(
user_id=auth.user_id,
code=body.code,
wallet_address=body.wallet_address,
)
return {'crypto_wallet': user.crypto_wallet}
@account_settings_router.post(path='/email/start', response_class=ORJSONResponse, status_code=status.HTTP_200_OK)
async def change_email_start(
request: Request,
auth: AuthContext = Depends(require_access_token),
command: ChangeEmailStartCommand = Depends(get_change_email_start_command),
):
result = await command(user_id=auth.user_id)
return {'success': result}
@account_settings_router.post(path='/email/confirm-old', response_class=ORJSONResponse, status_code=status.HTTP_200_OK)
async def change_email_confirm_old(
request: Request,
body: ChangeEmailConfirmOldRequest,
auth: AuthContext = Depends(require_access_token),
command: ChangeEmailConfirmOldCommand = Depends(get_change_email_confirm_old_command),
):
result = await command(user_id=auth.user_id, code=body.code, new_email=body.new_email)
return {'success': result}
@account_settings_router.post(path='/email/complete', response_class=ORJSONResponse, status_code=status.HTTP_200_OK)
async def change_email_complete(
request: Request,
body: ChangeEmailCompleteRequest,
auth: AuthContext = Depends(require_access_token),
command: ChangeEmailCompleteCommand = Depends(get_change_email_complete_command),
):
result = await command(user_id=auth.user_id, code=body.code)
return {'success': result}
@account_settings_router.post(path='/password/start', response_class=ORJSONResponse, status_code=status.HTTP_200_OK)
async def change_password_start(
request: Request,
auth: AuthContext = Depends(require_access_token),
command: ChangePasswordStartCommand = Depends(get_change_password_start_command),
):
result = await command(user_id=auth.user_id)
return {'success': result}
@account_settings_router.post(path='/password/complete', response_class=ORJSONResponse, status_code=status.HTTP_200_OK)
async def change_password_complete(
request: Request,
body: ChangePasswordConfirmRequest,
auth: AuthContext = Depends(require_access_token),
command: ChangePasswordCompleteCommand = Depends(get_change_password_complete_command),
):
result = await command(
user_id=auth.user_id,
code=body.code,
new_password=body.new_password,
confirm_password=body.confirm_password,
)
return {'success': result}
@account_settings_router.post(path='/bank/start', response_class=ORJSONResponse, status_code=status.HTTP_200_OK)
async def bank_details_start(
request: Request,
auth: AuthContext = Depends(require_access_token),
command: UpdateBankDetailsStartCommand = Depends(get_update_bank_details_start_command),
):
result = await command(user_id=auth.user_id)
return {'success': result}
@account_settings_router.post(path='/bank/complete', response_class=ORJSONResponse, status_code=status.HTTP_200_OK)
async def bank_details_complete(
request: Request,
body: BankConfirmRequest,
auth: AuthContext = Depends(require_access_token),
command: UpdateBankDetailsCompleteCommand = Depends(get_update_bank_details_complete_command),
):
user = await command(
user_id=auth.user_id,
code=body.code,
bik=body.bik,
account_number=body.account_number,
card_number=body.card_number,
)
return ORJSONResponse(
status_code=status.HTTP_200_OK,
content={
'bik': user.bik,
'account_number': user.account_number,
'card_number': user.card_number,
},
)