feat: allow creating/update user with nostr npub1 pubkey (#3298)

This commit is contained in:
Tiago Vasconcelos
2025-08-21 16:35:23 +02:00
committed by GitHub
parent 5ba06d42d0
commit ef371e303c
2 changed files with 94 additions and 2 deletions
+7
View File
@@ -47,6 +47,7 @@ from lnbits.helpers import (
)
from lnbits.settings import EditableSettings, settings
from lnbits.utils.exchange_rates import allowed_currencies
from lnbits.utils.nostr import normalize_public_key
users_router = APIRouter(
prefix="/users/api/v1", dependencies=[Depends(check_admin)], tags=["Users"]
@@ -94,6 +95,9 @@ async def api_create_user(data: CreateUser) -> CreateUser:
data.extra = data.extra or UserExtra()
data.extra.provider = data.extra.provider or "lnbits"
if data.pubkey:
data.pubkey = normalize_public_key(data.pubkey)
account = Account(
id=uuid4().hex,
username=data.username,
@@ -127,6 +131,9 @@ async def api_update_user(
HTTPStatus.BAD_REQUEST, "Use 'reset password' functionality."
)
if data.pubkey:
data.pubkey = normalize_public_key(data.pubkey)
account = Account(
id=user_id,
username=data.username,