mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-01-18 21:32:38 +01:00
fix: always create default wallet for user (#2580)
* fix: always create default wallet for user
* no assert in api
---------
Co-authored-by: dni ⚡ <office@dnilabs.com>
This commit is contained in:
parent
1bee84d419
commit
7d1e22c7de
@ -785,6 +785,7 @@ async def create_user_account(
|
|||||||
email: Optional[str] = None,
|
email: Optional[str] = None,
|
||||||
username: Optional[str] = None,
|
username: Optional[str] = None,
|
||||||
password: Optional[str] = None,
|
password: Optional[str] = None,
|
||||||
|
wallet_name: Optional[str] = None,
|
||||||
user_config: Optional[UserConfig] = None,
|
user_config: Optional[UserConfig] = None,
|
||||||
) -> User:
|
) -> User:
|
||||||
if not settings.new_accounts_allowed:
|
if not settings.new_accounts_allowed:
|
||||||
@ -805,6 +806,8 @@ async def create_user_account(
|
|||||||
password = pwd_context.hash(password) if password else None
|
password = pwd_context.hash(password) if password else None
|
||||||
|
|
||||||
account = await create_account(user_id, username, email, password, user_config)
|
account = await create_account(user_id, username, email, password, user_config)
|
||||||
|
wallet = await create_wallet(user_id=account.id, wallet_name=wallet_name)
|
||||||
|
account.wallets = [wallet]
|
||||||
|
|
||||||
for ext_id in settings.lnbits_user_default_extensions:
|
for ext_id in settings.lnbits_user_default_extensions:
|
||||||
await update_user_extension(user_id=account.id, extension=ext_id, active=True)
|
await update_user_extension(user_id=account.id, extension=ext_id, active=True)
|
||||||
|
@ -36,9 +36,6 @@ from lnbits.utils.exchange_rates import (
|
|||||||
satoshis_amount_as_fiat,
|
satoshis_amount_as_fiat,
|
||||||
)
|
)
|
||||||
|
|
||||||
from ..crud import (
|
|
||||||
create_wallet,
|
|
||||||
)
|
|
||||||
from ..services import create_user_account, perform_lnurlauth
|
from ..services import create_user_account, perform_lnurlauth
|
||||||
|
|
||||||
# backwards compatibility for extension
|
# backwards compatibility for extension
|
||||||
@ -69,8 +66,8 @@ async def api_create_account(data: CreateWallet) -> Wallet:
|
|||||||
status_code=HTTPStatus.FORBIDDEN,
|
status_code=HTTPStatus.FORBIDDEN,
|
||||||
detail="Account creation is disabled.",
|
detail="Account creation is disabled.",
|
||||||
)
|
)
|
||||||
account = await create_user_account()
|
account = await create_user_account(wallet_name=data.name)
|
||||||
return await create_wallet(user_id=account.id, wallet_name=data.name)
|
return account.wallets[0]
|
||||||
|
|
||||||
|
|
||||||
@api_router.get("/api/v1/lnurlscan/{code}")
|
@api_router.get("/api/v1/lnurlscan/{code}")
|
||||||
|
Loading…
Reference in New Issue
Block a user