feat: usermanager (#2139)

* feat: usermanager

---------

Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
This commit is contained in:
dni ⚡
2024-05-10 12:06:46 +02:00
committed by GitHub
co-authored by Vlad Stan
parent eae5002b69
commit 9ca14f200d
19 changed files with 961 additions and 144 deletions
+1 -27
View File
@@ -10,12 +10,10 @@ from fastapi import APIRouter, Depends
from fastapi.responses import FileResponse
from starlette.exceptions import HTTPException
from lnbits.core.crud import get_wallet
from lnbits.core.models import CreateTopup, User
from lnbits.core.models import User
from lnbits.core.services import (
get_balance_delta,
update_cached_settings,
update_wallet_balance,
)
from lnbits.core.tasks import api_invoice_listeners
from lnbits.decorators import check_admin, check_super_user
@@ -104,30 +102,6 @@ async def api_restart_server() -> dict[str, str]:
return {"status": "Success"}
@admin_router.put(
"/api/v1/topup",
name="Topup",
status_code=HTTPStatus.OK,
dependencies=[Depends(check_super_user)],
)
async def api_topup_balance(data: CreateTopup) -> dict[str, str]:
try:
await get_wallet(data.id)
except Exception as exc:
raise HTTPException(
status_code=HTTPStatus.FORBIDDEN, detail="wallet does not exist."
) from exc
if settings.lnbits_backend_wallet_class == "VoidWallet":
raise HTTPException(
status_code=HTTPStatus.FORBIDDEN, detail="VoidWallet active"
)
await update_wallet_balance(wallet_id=data.id, amount=int(data.amount))
return {"status": "Success"}
@admin_router.get(
"/api/v1/backup",
status_code=HTTPStatus.OK,