mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-01-18 21:32:38 +01:00
fix wallet key permission for create
This commit is contained in:
parent
32ea1106f9
commit
e42fdde2ac
@ -5,7 +5,13 @@ from fastapi import Query
|
||||
from fastapi.params import Depends
|
||||
from starlette.exceptions import HTTPException
|
||||
|
||||
from lnbits.decorators import WalletTypeInfo, get_key_type, require_admin_key
|
||||
from lnbits.decorators import (
|
||||
WalletAdminKeyChecker,
|
||||
WalletInvoiceKeyChecker,
|
||||
WalletTypeInfo,
|
||||
get_key_type,
|
||||
require_admin_key,
|
||||
)
|
||||
from lnbits.extensions.satspay import satspay_ext
|
||||
|
||||
from .crud import (
|
||||
@ -20,20 +26,22 @@ from .models import CreateCharge
|
||||
|
||||
#############################CHARGES##########################
|
||||
|
||||
@satspay_ext.post("/api/v1/charge", dependencies=[Depends(WalletInvoiceKeyChecker())])
|
||||
async def api_charge_create(
|
||||
data: CreateCharge,
|
||||
wallet: WalletTypeInfo = Depends(get_key_type)
|
||||
):
|
||||
charge = await create_charge(user=wallet.wallet.user, data=data)
|
||||
return charge.dict()
|
||||
|
||||
@satspay_ext.post("/api/v1/charge")
|
||||
@satspay_ext.put("/api/v1/charge/{charge_id}")
|
||||
async def api_charge_create_or_update(
|
||||
@satspay_ext.put("/api/v1/charge/{charge_id}", dependencies=[Depends(WalletAdminKeyChecker())])
|
||||
async def api_charge_update(
|
||||
data: CreateCharge,
|
||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
||||
charge_id=None,
|
||||
):
|
||||
if not charge_id:
|
||||
charge = await create_charge(user=wallet.wallet.user, data=data)
|
||||
return charge.dict()
|
||||
else:
|
||||
charge = await update_charge(charge_id=charge_id, data=data)
|
||||
return charge.dict()
|
||||
charge = await update_charge(charge_id=charge_id, data=data)
|
||||
return charge.dict()
|
||||
|
||||
|
||||
@satspay_ext.get("/api/v1/charges")
|
||||
|
Loading…
Reference in New Issue
Block a user