Skip to content

Commit

Permalink
Fix: device activation
Browse files Browse the repository at this point in the history
  • Loading branch information
Rotheem committed Jan 15, 2025
1 parent a774e63 commit 8726223
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions app/core/myeclpay/endpoints_myeclpay.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,7 @@ async def create_user_devices(
"activate_myeclpay_device_mail.html",
).render(
{
"activation_link": f"{settings.CLIENT_URL}myeclpay/users/me/wallet/devices/activate/{activation_token}",
"activation_link": f"{settings.CLIENT_URL}myeclpay/users/me/wallet/devices/activate?token={activation_token}",
},
)
background_tasks.add_task(
Expand All @@ -1284,20 +1284,19 @@ async def create_user_devices(


@router.get(
"/myeclpay/users/me/wallet/devices/activate/{activation_token}",
"/myeclpay/users/me/wallet/devices/activate",
status_code=200,
)
async def activate_user_device(
activation_token: str,
token: str,
db: AsyncSession = Depends(get_db),
user: CoreUser = Depends(is_user()),
):
"""
Activate a wallet device
"""

wallet_device = await cruds_myeclpay.get_wallet_device_by_activation_token(
activation_token=activation_token,
activation_token=token,
db=db,
)

Expand All @@ -1319,8 +1318,20 @@ async def activate_user_device(
db=db,
)

await db.commit()

wallet = await cruds_myeclpay.get_wallet(
wallet_id=wallet_device.wallet_id,
db=db,
)
if wallet is None:
raise HTTPException(
status_code=404,
detail="Wallet does not exist",
)

hyperion_error_logger.info(
f"Wallet device {wallet_device.id} activated by user {user.id}",
f"Wallet device {wallet_device.id} activated by user {wallet.user}",
)

return "Wallet device activated"
Expand Down

0 comments on commit 8726223

Please sign in to comment.