Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f01c91e3e | ||
|
|
ba5005fc44 | ||
|
|
2329770acd | ||
|
|
7d98c6b080 | ||
|
|
5f4e889d3a | ||
|
|
fe774ae1a1 | ||
|
|
21e02cb20e |
@@ -18,7 +18,7 @@ RUN uv sync --all-extras
|
||||
ENV LNBITS_PORT="5000"
|
||||
ENV LNBITS_HOST="0.0.0.0"
|
||||
ENV LNBITS_BACKEND_WALLET_CLASS="BoltzWallet"
|
||||
ENV FUNDING_SOURCE_MAX_RETRIES=10
|
||||
ENV FUNDING_SOURCE_MAX_RETRIES="10"
|
||||
|
||||
# Boltzd
|
||||
ENV BOLTZ_CLIENT_ENDPOINT="127.0.0.1:9002"
|
||||
|
||||
@@ -2,15 +2,17 @@ ARG LNBITS_TAG=latest
|
||||
|
||||
FROM lnbits/lnbits:${LNBITS_TAG}
|
||||
|
||||
RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
|
||||
|
||||
RUN apt-get update && apt-get -y upgrade
|
||||
RUN apt-get install -y netcat-openbsd npm nodejs git
|
||||
RUN apt-get install -y ca-certificates curl gnupg netcat-openbsd git nodejs
|
||||
|
||||
RUN curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
ENV PATH="/root/.local/bin:$PATH"
|
||||
|
||||
# install sparksidecar
|
||||
RUN git clone https://github.com/lnbits/spark_sidecar
|
||||
RUN cd spark_sidecar && npm install
|
||||
RUN cd spark_sidecar && npm ci
|
||||
|
||||
# Reinstall dependencies for lnbits just in case (needed for CMD usage)
|
||||
RUN uv sync --all-extras
|
||||
@@ -22,7 +24,7 @@ ENV LNBITS_BACKEND_WALLET_CLASS="SparkL2Wallet"
|
||||
ENV LNBITS_RESERVE_FEE_MIN="20000"
|
||||
ENV LNBITS_RESERVE_FEE_PERCENT="1"
|
||||
ENV LNBITS_FUNDING_SOURCE_PAY_INVOICE_WAIT_SECONDS="20"
|
||||
ENV FUNDING_SOURCE_MAX_RETRIES=10
|
||||
ENV FUNDING_SOURCE_MAX_RETRIES="10"
|
||||
|
||||
# spark sidecar
|
||||
ENV SPARK_NETWORK="MAINNET"
|
||||
|
||||
@@ -105,7 +105,8 @@ async def get_settings_field(
|
||||
)
|
||||
if not row:
|
||||
return None
|
||||
return SettingsField(id=row["id"], value=json.loads(row["value"]), tag=row["tag"])
|
||||
value = json.loads(row["value"]) if row["value"] else None
|
||||
return SettingsField(id=row["id"], value=value, tag=row["tag"])
|
||||
|
||||
|
||||
async def set_settings_field(id_: str, value: Any | None, tag: str | None = "core"):
|
||||
|
||||
@@ -173,6 +173,12 @@ async def check_admin_settings():
|
||||
if account and account.extra and account.extra.provider == "env":
|
||||
settings.first_install = True
|
||||
|
||||
if settings.has_first_install_token_changed():
|
||||
logger.warning("First install token is changed. Resetting admin settings.")
|
||||
new_settings = await init_admin_settings()
|
||||
settings.super_user = new_settings.super_user
|
||||
settings.first_install = True
|
||||
|
||||
logger.success(
|
||||
"✔️ Admin UI is enabled. run `uv run lnbits-cli superuser` "
|
||||
"to get the superuser."
|
||||
|
||||
@@ -12,6 +12,7 @@ from fastapi.responses import JSONResponse, RedirectResponse
|
||||
from fastapi_sso.sso.base import OpenID, SSOBase
|
||||
from loguru import logger
|
||||
|
||||
from lnbits.core.crud.settings import set_settings_field
|
||||
from lnbits.core.crud.users import (
|
||||
get_user_access_control_lists,
|
||||
update_user_access_control_list,
|
||||
@@ -532,6 +533,13 @@ async def first_install(data: UpdateSuperuserPassword) -> JSONResponse:
|
||||
account.hash_password(data.password)
|
||||
await update_account(account)
|
||||
settings.first_install = False
|
||||
|
||||
# only confrm it after the super user has been successfully updated
|
||||
if settings.first_install_token:
|
||||
settings.first_install_token_confirmed = data.first_install_token
|
||||
await set_settings_field(
|
||||
"first_install_token_confirmed", data.first_install_token
|
||||
)
|
||||
return _auth_success_response(account.username, account.id, account.email)
|
||||
|
||||
|
||||
|
||||
@@ -447,6 +447,7 @@ class SecuritySettings(LNbitsSettings):
|
||||
|
||||
lnbits_max_outgoing_payment_amount_sats: int = Field(default=10_000_000, ge=0)
|
||||
lnbits_max_incoming_payment_amount_sats: int = Field(default=10_000_000, ge=0)
|
||||
first_install_token_confirmed: str | None = Field(default=None)
|
||||
|
||||
def is_wallet_max_balance_exceeded(self, amount):
|
||||
return (
|
||||
@@ -1015,6 +1016,13 @@ class EnvSettings(LNbitsSettings):
|
||||
def has_default_extension_path(self) -> bool:
|
||||
return self.lnbits_extensions_path == "lnbits"
|
||||
|
||||
def has_first_install_token_changed(self) -> bool:
|
||||
if not self.first_install_token:
|
||||
return False
|
||||
if not settings.first_install_token_confirmed:
|
||||
return False
|
||||
return self.first_install_token != settings.first_install_token_confirmed
|
||||
|
||||
def check_auth_secret_key(self):
|
||||
if self.auth_secret_key:
|
||||
return
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -1,105 +0,0 @@
|
||||
window.app.component('lnbits-dialog', {
|
||||
template: '#lnbits-dialog',
|
||||
|
||||
props: {
|
||||
show: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
position: {
|
||||
type: String,
|
||||
default: 'top'
|
||||
},
|
||||
persistent: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
showCancel: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
},
|
||||
cancelLabel: {
|
||||
type: String,
|
||||
default: 'Close'
|
||||
},
|
||||
cancelColor: {
|
||||
type: String,
|
||||
default: 'grey'
|
||||
},
|
||||
action: {
|
||||
type: Object,
|
||||
default: null
|
||||
},
|
||||
secondaryAction: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
|
||||
emits: ['update:show', 'hide', 'cancel', 'action', 'secondary-action'],
|
||||
|
||||
computed: {
|
||||
hasAction() {
|
||||
return !!(this.action && this.action.label)
|
||||
},
|
||||
hasSecondaryAction() {
|
||||
return !!(this.secondaryAction && this.secondaryAction.label)
|
||||
},
|
||||
|
||||
actionProps() {
|
||||
const action = this.action || {}
|
||||
const obj = {
|
||||
label: action.label || 'Action',
|
||||
color: action.color || 'primary',
|
||||
loading: !!action.loading,
|
||||
disable: !!action.disable,
|
||||
closePopup: !!action.closePopup
|
||||
}
|
||||
if (action.icon) {
|
||||
obj.icon = action.icon
|
||||
}
|
||||
return obj
|
||||
},
|
||||
secondaryActionProps() {
|
||||
const action = this.secondaryAction || {}
|
||||
const obj = {
|
||||
label: action.label || 'Secondary',
|
||||
color: action.color || 'secondary',
|
||||
loading: !!action.loading,
|
||||
disable: !!action.disable,
|
||||
closePopup: !!action.closePopup
|
||||
}
|
||||
if (action.icon) {
|
||||
obj.icon = action.icon
|
||||
}
|
||||
return obj
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
handleModelUpdate(value) {
|
||||
this.$emit('update:show', value)
|
||||
},
|
||||
|
||||
handleHide() {
|
||||
this.handleModelUpdate(false)
|
||||
this.$emit('hide')
|
||||
},
|
||||
|
||||
handleCancel() {
|
||||
this.$emit('cancel')
|
||||
},
|
||||
|
||||
handleAction() {
|
||||
this.$emit('action')
|
||||
},
|
||||
|
||||
handleSecondaryAction() {
|
||||
this.$emit('secondary-action')
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -70,7 +70,6 @@
|
||||
"js/components/admin/lnbits-admin-site-customisation.js",
|
||||
"js/components/admin/lnbits-admin-assets-config.js",
|
||||
"js/components/admin/lnbits-admin-audit.js",
|
||||
"js/components/lnbits-dialog.js",
|
||||
"js/components/lnbits-wallet-charts.js",
|
||||
"js/components/lnbits-wallet-api-docs.js",
|
||||
"js/components/lnbits-wallet-icon.js",
|
||||
|
||||
@@ -30,8 +30,7 @@ include('components/lnbits-wallet-share.vue') %} {%
|
||||
include('components/lnbits-wallet-charts.vue') %} {%
|
||||
include('components/lnbits-wallet-paylinks.vue') %} {%
|
||||
include('components/lnbits-wallet-extra.vue') %} {%
|
||||
include('components/lnbits-error.vue') %} {%
|
||||
include('components/lnbits-dialog.vue') %}
|
||||
include('components/lnbits-error.vue') %}
|
||||
|
||||
<template id="lnbits-manage">
|
||||
<q-list v-if="g.user" dense class="lnbits-drawer__q-list">
|
||||
|
||||
@@ -199,16 +199,12 @@
|
||||
</div>
|
||||
<div class="col-md-8 col-sm-12"></div>
|
||||
</div>
|
||||
<lnbits-dialog
|
||||
:show="exchangeData.showTickerConversion"
|
||||
:title="$t('create_ticker_converter')"
|
||||
:action="{
|
||||
label: 'Add Ticker Conversion'
|
||||
}"
|
||||
:cancel-label="$t('close')"
|
||||
@update:show="exchangeData.showTickerConversion = $event"
|
||||
@action="addExchangeTickerConversion()"
|
||||
>
|
||||
|
||||
<q-dialog v-model="exchangeData.showTickerConversion" position="top">
|
||||
<q-card class="q-pa-md q-pt-md lnbits__dialog-card">
|
||||
<div class="q-mb-md">
|
||||
<strong v-text="$t('create_ticker_converter')"></strong>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 q-mb-md">
|
||||
<q-select
|
||||
@@ -230,5 +226,20 @@
|
||||
</q-input>
|
||||
</div>
|
||||
</div>
|
||||
</lnbits-dialog>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
@click="addExchangeTickerConversion()"
|
||||
label="Add Ticker Conversion"
|
||||
color="primary"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
v-text="$t('close')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
@@ -125,14 +125,15 @@
|
||||
</q-expansion-item>
|
||||
</div>
|
||||
</q-list>
|
||||
<lnbits-dialog
|
||||
:show="showQRDialog"
|
||||
:position="'standard'"
|
||||
@update:show="showQRDialog = $event"
|
||||
>
|
||||
<q-dialog v-model="showQRDialog">
|
||||
<q-card class="q-pa-md">
|
||||
<q-card-section>
|
||||
<lnbits-qrcode :value="qrValue"></lnbits-qrcode>
|
||||
</q-card-section>
|
||||
</lnbits-dialog>
|
||||
<q-card-actions align="right">
|
||||
<q-btn flat :label="$t('close')" v-close-popup />
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
<template id="lnbits-dialog">
|
||||
<q-dialog
|
||||
:model-value="show"
|
||||
:position="position"
|
||||
:persistent="persistent"
|
||||
@update:model-value="handleModelUpdate"
|
||||
@hide="handleHide"
|
||||
>
|
||||
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
||||
<!-- Header with optional title -->
|
||||
<q-card-section v-if="title">
|
||||
<div class="text-h6" v-text="title"></div>
|
||||
</q-card-section>
|
||||
|
||||
<!-- Main content slot -->
|
||||
<q-card-section>
|
||||
<slot></slot>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-actions
|
||||
v-if="showCancel || hasAction || hasSecondaryAction"
|
||||
class="q-mt-lg"
|
||||
align="right"
|
||||
>
|
||||
<q-btn
|
||||
v-if="showCancel"
|
||||
v-close-popup
|
||||
flat
|
||||
:color="cancelColor"
|
||||
:label="cancelLabel"
|
||||
@click="handleCancel"
|
||||
></q-btn>
|
||||
|
||||
<q-space></q-space>
|
||||
|
||||
<q-btn
|
||||
v-if="hasSecondaryAction"
|
||||
:icon="secondaryActionProps.icon"
|
||||
:color="secondaryActionProps.color"
|
||||
:label="secondaryActionProps.label"
|
||||
:loading="secondaryActionProps.loading"
|
||||
:disable="secondaryActionProps.disable"
|
||||
@click="handleSecondaryAction"
|
||||
v-close-popup="secondaryActionProps.closePopup"
|
||||
class="q-mr-sm"
|
||||
></q-btn>
|
||||
|
||||
<q-btn
|
||||
v-if="hasAction"
|
||||
:icon="actionProps.icon"
|
||||
:color="actionProps.color"
|
||||
:label="actionProps.label"
|
||||
:loading="actionProps.loading"
|
||||
:disable="actionProps.disable"
|
||||
@click="handleAction"
|
||||
v-close-popup="actionProps.closePopup"
|
||||
></q-btn>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
@@ -394,16 +394,9 @@
|
||||
></span>
|
||||
</i>
|
||||
</q-td>
|
||||
<lnbits-dialog
|
||||
:show="props.expand"
|
||||
:cancel-label="$t('close')"
|
||||
:action="{
|
||||
label: $t('check_payment'),
|
||||
icon: 'refresh'
|
||||
}"
|
||||
@update:show="props.expand = $event"
|
||||
@action="checkPayment(props.row.payment_hash)"
|
||||
>
|
||||
<q-dialog v-model="props.expand" :props="props" position="top">
|
||||
<q-card class="q-pa-sm q-pt-xl lnbits__dialog-card">
|
||||
<q-card-section>
|
||||
<q-list bordered separator>
|
||||
<q-expansion-item
|
||||
expand-separator
|
||||
@@ -468,7 +461,9 @@
|
||||
</q-list>
|
||||
|
||||
<div
|
||||
v-if="props.row.isIn && props.row.isPending && props.row.bolt11"
|
||||
v-if="
|
||||
props.row.isIn && props.row.isPending && props.row.bolt11
|
||||
"
|
||||
>
|
||||
<div v-if="props.row.extra.fiat_payment_request">
|
||||
<lnbits-qrcode
|
||||
@@ -484,24 +479,27 @@
|
||||
></lnbits-qrcode>
|
||||
</div>
|
||||
</div>
|
||||
</lnbits-dialog>
|
||||
<lnbits-dialog
|
||||
:show="hodlInvoice.show"
|
||||
:cancel-label="$t('close')"
|
||||
:action="{
|
||||
label: $t('cancel_invoice'),
|
||||
color: 'grey',
|
||||
closePopup: true
|
||||
}"
|
||||
:secondary-action="{
|
||||
label: $t('settle_invoice'),
|
||||
color: 'grey',
|
||||
closePopup: true
|
||||
}"
|
||||
@update:show="hodlInvoice.show = $event"
|
||||
@action="cancelHoldInvoice(hodlInvoice.payment.payment_hash)"
|
||||
@secondary-action="settleHoldInvoice(hodlInvoice.preimage)"
|
||||
>
|
||||
<div class="row q-mt-md">
|
||||
<q-btn
|
||||
outline
|
||||
color="grey"
|
||||
@click="checkPayment(props.row.payment_hash)"
|
||||
icon="refresh"
|
||||
:label="$t('payment_check')"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
:label="$t('close')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
<q-dialog v-model="hodlInvoice.show" position="top">
|
||||
<q-card class="q-pa-sm q-pt-xl lnbits__dialog-card">
|
||||
<q-card-section>
|
||||
<q-item-label class="text-h6">
|
||||
<span v-text="$t('hold_invoice')"></span>
|
||||
@@ -522,7 +520,33 @@
|
||||
>
|
||||
</q-input>
|
||||
</q-card-section>
|
||||
</lnbits-dialog>
|
||||
<q-card-section class="row q-gutter-x-sm">
|
||||
<q-btn
|
||||
@click="settleHoldInvoice(hodlInvoice.preimage)"
|
||||
outline
|
||||
v-close-popup
|
||||
color="grey"
|
||||
:label="$t('settle_invoice')"
|
||||
>
|
||||
</q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
outline
|
||||
color="grey"
|
||||
class="q-ml-sm"
|
||||
@click="cancelHoldInvoice(hodlInvoice.payment.payment_hash)"
|
||||
:label="$t('cancel_invoice')"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
:label="$t('close')"
|
||||
></q-btn>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</q-tr>
|
||||
</template>
|
||||
</q-table>
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
<template id="lnbits-qrcode-scanner">
|
||||
<lnbits-dialog
|
||||
:show="showScanner"
|
||||
:cancel-label="$t('cancel')"
|
||||
@update:show="showScanner = $event"
|
||||
@cancel="reset"
|
||||
>
|
||||
<q-dialog v-model="showScanner" position="top">
|
||||
<q-card class="q-pa-lg q-pt-xl">
|
||||
<div class="text-center q-mb-lg">
|
||||
<qrcode-stream
|
||||
@detect="detect"
|
||||
@@ -12,5 +8,15 @@
|
||||
class="rounded-borders"
|
||||
></qrcode-stream>
|
||||
</div>
|
||||
</lnbits-dialog>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
@click="reset"
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
:label="$t('cancel')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
@@ -8,17 +8,9 @@
|
||||
icon="edit"
|
||||
style="position: relative; left: -15px; bottom: -10px"
|
||||
></q-btn>
|
||||
<lnbits-dialog
|
||||
:show="icon.show"
|
||||
:action="{
|
||||
label: 'Save Icon',
|
||||
disable: !icon.data.icon
|
||||
}"
|
||||
@update:show="icon.show = $event"
|
||||
@action="setIcon"
|
||||
@hide="icon.data = {}"
|
||||
>
|
||||
<q-form class="q-gutter-md">
|
||||
<q-dialog v-model="icon.show" position="top">
|
||||
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
||||
<q-form @submit="setIcon" class="q-gutter-md">
|
||||
<div class="q-gutter-sm q-pa-sm flex flex-wrap justify-center">
|
||||
<q-btn
|
||||
v-for="(thisIcon, index) in icon.options"
|
||||
@@ -49,7 +41,16 @@
|
||||
class="q-mr-xs"
|
||||
></q-btn>
|
||||
</div>
|
||||
<q-btn
|
||||
unelevated
|
||||
color="primary"
|
||||
:disable="!icon.data.icon"
|
||||
type="submit"
|
||||
>
|
||||
Save Icon
|
||||
</q-btn>
|
||||
</div>
|
||||
</q-form>
|
||||
</lnbits-dialog>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
@@ -1,24 +1,11 @@
|
||||
<template id="lnbits-wallet-new">
|
||||
<lnbits-dialog
|
||||
:show="showNewWalletDialog"
|
||||
:title="$t('add_new_wallet')"
|
||||
:action="{
|
||||
label: $t('add_wallet'),
|
||||
closePopup: true
|
||||
}"
|
||||
:secondary-action="
|
||||
isLightningShared
|
||||
? {
|
||||
label: $t('reject_wallet'),
|
||||
color: 'negative',
|
||||
closePopup: true
|
||||
}
|
||||
: null
|
||||
"
|
||||
@update:show="showNewWalletDialog = $event"
|
||||
@action="submitAddWallet"
|
||||
@secondary-action="submitRejectWalletInvitation"
|
||||
>
|
||||
<q-dialog v-model="showNewWalletDialog" position="top">
|
||||
<q-card class="q-pa-lg q-pt-md lnbits__dialog-card">
|
||||
<q-card-section>
|
||||
<div class="text-h6">
|
||||
<span v-text="$t('add_new_wallet')"></span>
|
||||
</div>
|
||||
</q-card-section>
|
||||
<q-card-section v-if="g.user.walletInvitesCount">
|
||||
<q-badge
|
||||
@click="g.newWalletType = 'lightning-shared'"
|
||||
@@ -68,5 +55,40 @@
|
||||
<span v-text="$t('shared_wallet_desc')" class="q-mt-lg"></span>
|
||||
</div>
|
||||
</q-card-section>
|
||||
</lnbits-dialog>
|
||||
|
||||
<q-card-actions class="text-primary">
|
||||
<div class="row full-width">
|
||||
<div class="col-md-4">
|
||||
<q-btn
|
||||
flat
|
||||
:label="$t('cancel')"
|
||||
class="float-left"
|
||||
v-close-popup
|
||||
></q-btn>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<q-btn
|
||||
v-if="isLightningShared"
|
||||
:disabled="!wallet.sharedWalletId"
|
||||
flat
|
||||
:label="$t('reject_wallet')"
|
||||
v-close-popup
|
||||
color="negative"
|
||||
@click="submitRejectWalletInvitation()"
|
||||
></q-btn>
|
||||
<span v-else></span>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<q-btn
|
||||
flat
|
||||
:label="$t('add_wallet')"
|
||||
v-close-popup
|
||||
@click="submitAddWallet()"
|
||||
class="float-right"
|
||||
></q-btn>
|
||||
</div>
|
||||
</div>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
@@ -1231,16 +1231,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<lnbits-dialog
|
||||
:show="apiAcl.showPasswordDialog"
|
||||
title="Password Required"
|
||||
:action="{
|
||||
label: $t('ok')
|
||||
}"
|
||||
@update:show="apiAcl.showPasswordDialog = $event"
|
||||
@action="runPasswordGuardedFunction()"
|
||||
>
|
||||
<div class="row q-col-gutter-md">
|
||||
<q-dialog v-model="apiAcl.showPasswordDialog" position="top">
|
||||
<q-card class="q-pa-md q-pt-md lnbits__dialog-card">
|
||||
<strong>User Password</strong>
|
||||
<div class="row q-mt-md q-col-gutter-md">
|
||||
<div class="col-12">
|
||||
<q-input
|
||||
v-model="apiAcl.password"
|
||||
@@ -1253,39 +1247,55 @@
|
||||
</q-input>
|
||||
</div>
|
||||
</div>
|
||||
</lnbits-dialog>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
v-text="$t('cancel')"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
@click="runPasswordGuardedFunction()"
|
||||
:label="$t('ok')"
|
||||
color="primary"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<lnbits-dialog
|
||||
:show="apiAcl.showNewAclDialog"
|
||||
title="New API Access Control List"
|
||||
:action="{
|
||||
label: 'Create'
|
||||
}"
|
||||
:cancel-label="$t('close')"
|
||||
@update:show="apiAcl.showNewAclDialog = $event"
|
||||
@action="addApiACL()"
|
||||
>
|
||||
<div class="row q-col-gutter-md">
|
||||
<q-dialog v-model="apiAcl.showNewAclDialog" position="top">
|
||||
<q-card class="q-pa-md q-pt-md lnbits__dialog-card">
|
||||
<strong>New API Access Control List</strong>
|
||||
<div class="row q-mt-md q-col-gutter-md">
|
||||
<div class="col-12">
|
||||
<q-input v-model="apiAcl.newAclName" dense filled label="ACL Name">
|
||||
</q-input>
|
||||
</div>
|
||||
</div>
|
||||
</lnbits-dialog>
|
||||
|
||||
<lnbits-dialog
|
||||
:show="apiAcl.showNewTokenDialog"
|
||||
title="New API Token"
|
||||
:action="{
|
||||
label: 'Create'
|
||||
}"
|
||||
:cancel-label="$t('close')"
|
||||
@update:show="apiAcl.showNewTokenDialog = $event"
|
||||
@action="generateApiToken()"
|
||||
>
|
||||
<div class="row q-col-gutter-md">
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn @click="addApiACL()" label="Create" color="primary"></q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
v-text="$t('close')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
<q-dialog v-model="apiAcl.showNewTokenDialog" position="top">
|
||||
<q-card class="q-pa-md q-pt-md lnbits__dialog-card">
|
||||
<strong>New API Token</strong>
|
||||
<div class="row q-col-gutter-md q-mt-md">
|
||||
<div class="col-12">
|
||||
<q-input v-model="apiAcl.newTokenName" dense filled label="Token Name">
|
||||
<q-input
|
||||
v-model="apiAcl.newTokenName"
|
||||
dense
|
||||
filled
|
||||
label="Token Name"
|
||||
>
|
||||
</q-input>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
@@ -1303,7 +1313,10 @@
|
||||
transition-show="scale"
|
||||
transition-hide="scale"
|
||||
>
|
||||
<q-date v-model="apiAcl.newTokenExpiry" mask="YYYY-MM-DD HH:mm">
|
||||
<q-date
|
||||
v-model="apiAcl.newTokenExpiry"
|
||||
mask="YYYY-MM-DD HH:mm"
|
||||
>
|
||||
<div class="row items-center justify-end">
|
||||
<q-btn v-close-popup label="Close" color="primary" flat />
|
||||
</div>
|
||||
@@ -1334,28 +1347,26 @@
|
||||
</q-input>
|
||||
</div>
|
||||
</div>
|
||||
</lnbits-dialog>
|
||||
|
||||
<lnbits-dialog
|
||||
:show="labelsDialog.show"
|
||||
:title="$t('label')"
|
||||
:action="{
|
||||
label: g.user.extra.labels.some(
|
||||
label => label.name === labelsDialog.data.name
|
||||
)
|
||||
? $t('update_label')
|
||||
: $t('add_label'),
|
||||
disable: !labelsDialog.data.name || !labelsDialog.data.color
|
||||
}"
|
||||
:cancel-label="$t('cancel')"
|
||||
@update:show="labelsDialog.show = $event"
|
||||
@action="
|
||||
g.user.extra.labels.some(label => label.name === labelsDialog.data.name)
|
||||
? updateUserLabel()
|
||||
: addUserLabel()
|
||||
"
|
||||
>
|
||||
<div class="row q-col-gutter-md">
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
@click="generateApiToken()"
|
||||
label="Create"
|
||||
color="primary"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
v-text="$t('close')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
<q-dialog v-model="labelsDialog.show" position="top">
|
||||
<q-card class="q-pa-md q-pt-md lnbits__dialog-card">
|
||||
<strong v-text="$t('label')"></strong>
|
||||
<div class="row q-mt-md q-col-gutter-md">
|
||||
<div class="col-12">
|
||||
<q-input
|
||||
v-model="labelsDialog.data.name"
|
||||
@@ -1400,5 +1411,33 @@
|
||||
</q-input>
|
||||
</div>
|
||||
</div>
|
||||
</lnbits-dialog>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
v-text="$t('cancel')"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-if="
|
||||
g.user.extra.labels.some(
|
||||
label => label.name === labelsDialog.data.name
|
||||
)
|
||||
"
|
||||
@click="updateUserLabel()"
|
||||
:disable="!labelsDialog.data.name || !labelsDialog.data.color"
|
||||
:label="$t('update_label')"
|
||||
color="primary"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-else
|
||||
@click="addUserLabel()"
|
||||
:disable="!labelsDialog.data.name || !labelsDialog.data.color"
|
||||
:label="$t('add_label')"
|
||||
color="primary"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
@@ -170,17 +170,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<lnbits-dialog
|
||||
:show="auditDetailsDialog.show"
|
||||
:title="$t('http_request_details')"
|
||||
:action="{
|
||||
label: $t('copy'),
|
||||
icon: 'content_copy'
|
||||
}"
|
||||
:cancel-label="$t('close')"
|
||||
@update:show="auditDetailsDialog.show = $event"
|
||||
@action="utils.copyText(auditDetailsDialog.data)"
|
||||
>
|
||||
<q-dialog v-model="auditDetailsDialog.show" position="top">
|
||||
<q-card class="q-pa-md q-pt-md lnbits__dialog-card">
|
||||
<strong v-text="$t('http_request_details')"></strong>
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
@@ -188,5 +180,23 @@
|
||||
type="textarea"
|
||||
rows="25"
|
||||
></q-input>
|
||||
</lnbits-dialog>
|
||||
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
@click="utils.copyText(auditDetailsDialog.data)"
|
||||
icon="content_copy"
|
||||
color="grey"
|
||||
flat
|
||||
v-text="$t('copy')"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
v-text="$t('close')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
@@ -366,16 +366,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<lnbits-dialog
|
||||
:show="showUninstallDialog"
|
||||
:title="$t('warning')"
|
||||
:action="{
|
||||
label: $t('uninstall_confirm')
|
||||
}"
|
||||
:cancel-label="$t('cancel')"
|
||||
@update:show="showUninstallDialog = $event"
|
||||
@action="uninstallExtension()"
|
||||
>
|
||||
<q-dialog v-model="showUninstallDialog" position="top">
|
||||
<q-card class="q-pa-lg">
|
||||
<h6 class="q-my-md text-primary" v-text="$t('warning')"></h6>
|
||||
<p>
|
||||
<span v-text="$t('extension_uninstall_warning')"></span><br />
|
||||
<span v-text="$t('confirm_continue')"></span>
|
||||
@@ -392,21 +385,27 @@
|
||||
</q-tooltip>
|
||||
</q-checkbox>
|
||||
</div>
|
||||
</lnbits-dialog>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
outline
|
||||
color="grey"
|
||||
@click="uninstallExtension()"
|
||||
v-text="$t('uninstall_confirm')"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
v-text="$t('cancel')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<lnbits-dialog
|
||||
v-if="selectedExtension"
|
||||
:show="showDropDbDialog"
|
||||
:title="$t('warning')"
|
||||
:action="{
|
||||
label: $t('confirm'),
|
||||
color: 'red',
|
||||
disable: dropDbExtensionId !== selectedExtension.id
|
||||
}"
|
||||
:cancel-label="$t('cancel')"
|
||||
@update:show="showDropDbDialog = $event"
|
||||
@action="dropExtensionDb()"
|
||||
>
|
||||
<q-dialog v-model="showDropDbDialog" position="top">
|
||||
<q-card v-if="selectedExtension" class="q-pa-lg">
|
||||
<h6 class="q-my-md text-primary" v-text="$t('warning')"></h6>
|
||||
<p><span v-text="$t('extension_db_drop_warning')"></span><br /></p>
|
||||
<q-input
|
||||
v-model="dropDbExtensionId"
|
||||
@@ -431,7 +430,8 @@
|
||||
v-text="$t('cancel')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</lnbits-dialog>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<q-dialog v-model="showManageExtensionDialog" position="top">
|
||||
<q-card v-if="selectedRelease" class="q-pa-lg lnbits__dialog-card">
|
||||
@@ -1244,11 +1244,9 @@
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
<lnbits-dialog
|
||||
:show="paymentDialog.show"
|
||||
:cancel-label="$t('close')"
|
||||
@update:show="paymentDialog.show = $event"
|
||||
>
|
||||
<q-dialog v-model="paymentDialog.show" position="top">
|
||||
<q-card class="q-pa-md lnbits__dialog-card">
|
||||
<q-card-section>
|
||||
<q-responsive :ratio="1" class="q-mx-xl q-mb-xl">
|
||||
<lnbits-qrcode
|
||||
:value="paymentDialog.invoice"
|
||||
@@ -1256,20 +1254,21 @@
|
||||
class="rounded-borders"
|
||||
></lnbits-qrcode>
|
||||
</q-responsive>
|
||||
</lnbits-dialog>
|
||||
|
||||
<lnbits-dialog
|
||||
:show="showUpdateAllDialog"
|
||||
:title="$t('update')"
|
||||
:action="{
|
||||
label: $t('update')
|
||||
}"
|
||||
:cancel-label="$t('cancel')"
|
||||
@update:show="showUpdateAllDialog = $event"
|
||||
@action="updateSelectedExtensions()"
|
||||
>
|
||||
</q-card-section>
|
||||
<q-card-actions align="between">
|
||||
<q-btn v-close-popup flat color="grey" :label="$t('close')"></q-btn>
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
<q-dialog v-model="showUpdateAllDialog" position="top">
|
||||
<q-card class="q-pa-md q-pt-md lnbits__dialog-card">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h6 class="q-my-md" v-text="$t('update')"></h6>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="updatableExtensions?.length > 1" class="row">
|
||||
<div class="col-12 q-mb-md">
|
||||
<div class="col-12">
|
||||
<q-btn
|
||||
outline
|
||||
color="grey"
|
||||
@@ -1300,5 +1299,21 @@
|
||||
</div>
|
||||
</template>
|
||||
</q-virtual-scroll>
|
||||
</lnbits-dialog>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
@click="updateSelectedExtensions()"
|
||||
outline
|
||||
color="grey"
|
||||
v-text="$t('update')"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
v-text="$t('cancel')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
@@ -103,15 +103,8 @@
|
||||
</q-card-section>
|
||||
</q-tab-panel>
|
||||
<q-tab-panel name="channels">
|
||||
<lnbits-dialog
|
||||
:show="connectPeerDialog.show"
|
||||
:action="{
|
||||
label: $t('connect')
|
||||
}"
|
||||
:cancel-label="$t('cancel')"
|
||||
@update:show="connectPeerDialog.show = $event"
|
||||
@action="connectPeer"
|
||||
>
|
||||
<q-dialog v-model="connectPeerDialog.show" position="top">
|
||||
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
||||
<q-form class="q-gutter-md">
|
||||
<q-input
|
||||
dense
|
||||
@@ -121,19 +114,28 @@
|
||||
label="Node URI"
|
||||
hint="pubkey@host:port"
|
||||
></q-input>
|
||||
</q-form>
|
||||
</lnbits-dialog>
|
||||
|
||||
<lnbits-dialog
|
||||
:show="setFeeDialog.show"
|
||||
title="Set Channel Fee"
|
||||
:action="{
|
||||
label: $t('set')
|
||||
}"
|
||||
:cancel-label="$t('cancel')"
|
||||
@update:show="setFeeDialog.show = $event"
|
||||
@action="setChannelFee(setFeeDialog.channel_id)"
|
||||
>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
:label="$t('connect')"
|
||||
color="primary"
|
||||
@click="connectPeer"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
:label="$t('cancel')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<q-dialog v-model="setFeeDialog.show">
|
||||
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
||||
<label class="text-h6">Set Channel Fee</label>
|
||||
<p class="text-caption" v-text="setFeeDialog.channel_id"></p>
|
||||
<q-separator></q-separator>
|
||||
<q-form class="q-gutter-md">
|
||||
@@ -151,18 +153,27 @@
|
||||
v-model.number="setFeeDialog.data.fee_base_msat"
|
||||
label="Fee Base msat"
|
||||
></q-input>
|
||||
</q-form>
|
||||
</lnbits-dialog>
|
||||
|
||||
<lnbits-dialog
|
||||
:show="openChannelDialog.show"
|
||||
:action="{
|
||||
label: $t('open')
|
||||
}"
|
||||
:cancel-label="$t('cancel')"
|
||||
@update:show="openChannelDialog.show = $event"
|
||||
@action="openChannel"
|
||||
>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
:label="$t('set')"
|
||||
color="primary"
|
||||
@click="setChannelFee(setFeeDialog.channel_id)"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
:label="$t('cancel')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<q-dialog v-model="openChannelDialog.show">
|
||||
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
||||
<q-form class="q-gutter-md">
|
||||
<q-input
|
||||
dense
|
||||
@@ -186,7 +197,9 @@
|
||||
dense
|
||||
type="number"
|
||||
filled
|
||||
v-model.number="openChannelDialog.data.push_amount"
|
||||
v-model.number="
|
||||
openChannelDialog.data.push_amount
|
||||
"
|
||||
label="Push Amount"
|
||||
hint="This gifts sats to the other side!"
|
||||
></q-input>
|
||||
@@ -202,19 +215,27 @@
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
</q-form>
|
||||
</lnbits-dialog>
|
||||
|
||||
<lnbits-dialog
|
||||
:show="closeChannelDialog.show"
|
||||
title="Close Channel"
|
||||
:action="{
|
||||
label: $t('close')
|
||||
}"
|
||||
:cancel-label="$t('cancel')"
|
||||
@update:show="closeChannelDialog.show = $event"
|
||||
@action="closeChannel"
|
||||
>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
:label="$t('open')"
|
||||
color="primary"
|
||||
@click="openChannel"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
:label="$t('cancel')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<q-dialog v-model="closeChannelDialog.show" position="top">
|
||||
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
||||
<q-form class="q-gutter-md">
|
||||
<div>
|
||||
<q-checkbox
|
||||
@@ -222,8 +243,24 @@
|
||||
label="Force"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
:label="$t('close')"
|
||||
color="primary"
|
||||
@click="closeChannel"
|
||||
></q-btn>
|
||||
<q-btn
|
||||
v-close-popup
|
||||
flat
|
||||
color="grey"
|
||||
class="q-ml-auto"
|
||||
:label="$t('cancel')"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-form>
|
||||
</lnbits-dialog>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
<q-card-section class="q-pa-none">
|
||||
<div class="row q-col-gutter-lg">
|
||||
|
||||
@@ -446,17 +446,9 @@
|
||||
</div>
|
||||
</div>
|
||||
<div v-else-if="activeWallet.show">
|
||||
<lnbits-dialog
|
||||
:show="createWalletDialog.show"
|
||||
title="Create Wallet"
|
||||
:action="{
|
||||
label: 'Create',
|
||||
closePopup: true
|
||||
}"
|
||||
cancel-label="Cancel"
|
||||
@update:show="createWalletDialog.show = $event"
|
||||
@action="createWallet"
|
||||
>
|
||||
<q-dialog v-model="createWalletDialog.show" position="top">
|
||||
<q-card class="q-pa-md q-pt-md lnbits__dialog-card">
|
||||
<strong>Create Wallet</strong>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="row q-mt-lg">
|
||||
@@ -477,13 +469,27 @@
|
||||
filled
|
||||
dense
|
||||
v-model="createWalletDialog.data.currency"
|
||||
:options="g.allowedCurrencies"
|
||||
:options="{{ currencies | safe }}"
|
||||
></q-select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
v-close-popup
|
||||
@click="createWallet()"
|
||||
unelevated
|
||||
color="primary"
|
||||
type="submit"
|
||||
>Create</q-btn
|
||||
>
|
||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto"
|
||||
>Cancel</q-btn
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</lnbits-dialog>
|
||||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="row q-col-gutter-md q-mb-md">
|
||||
|
||||
@@ -15,7 +15,11 @@ from lnbits.settings import settings
|
||||
def log_server_info():
|
||||
logger.info("LNbits Info")
|
||||
if settings.first_install:
|
||||
if settings.has_first_install_token_changed():
|
||||
logger.success("This is a first install token reset.")
|
||||
else:
|
||||
logger.success("This is a fresh install of LNbits.")
|
||||
|
||||
if settings.first_install_token:
|
||||
logger.success(
|
||||
f"FIRST_INSTALL_TOKEN: `{settings.first_install_token}`. "
|
||||
|
||||
@@ -123,7 +123,6 @@
|
||||
"js/components/admin/lnbits-admin-site-customisation.js",
|
||||
"js/components/admin/lnbits-admin-assets-config.js",
|
||||
"js/components/admin/lnbits-admin-audit.js",
|
||||
"js/components/lnbits-dialog.js",
|
||||
"js/components/lnbits-wallet-charts.js",
|
||||
"js/components/lnbits-wallet-api-docs.js",
|
||||
"js/components/lnbits-wallet-icon.js",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "lnbits"
|
||||
version = "1.5.2-rc1"
|
||||
version = "1.5.3"
|
||||
requires-python = ">=3.10,<3.13"
|
||||
description = "LNbits, free and open-source Lightning wallet and accounts system."
|
||||
authors = [{ name = "Alan Bits", email = "alan@lnbits.com" }]
|
||||
|
||||
@@ -71,6 +71,7 @@ async def app(settings: Settings):
|
||||
username="superadmin",
|
||||
password="secret1234",
|
||||
password_repeat="secret1234",
|
||||
first_install_token=settings.first_install_token,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
from pathlib import Path
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
|
||||
from lnbits.core.crud import create_account, delete_account, get_account
|
||||
from lnbits.core.crud.settings import get_settings_field, set_settings_field
|
||||
from lnbits.core.db import db
|
||||
from lnbits.core.models import Account, UpdateSuperuserPassword, UserExtra
|
||||
from lnbits.core.services.users import check_admin_settings
|
||||
from lnbits.core.views.auth_api import first_install
|
||||
from lnbits.settings import settings
|
||||
|
||||
|
||||
async def _restore_setting_field(field_name: str, original_row) -> None:
|
||||
if original_row is None:
|
||||
await db.execute(
|
||||
"DELETE FROM system_settings WHERE id = :id AND tag = :tag",
|
||||
{"id": field_name, "tag": "core"},
|
||||
)
|
||||
return
|
||||
|
||||
await set_settings_field(field_name, original_row.value, original_row.tag)
|
||||
|
||||
|
||||
def test_has_first_install_token_changed_requires_a_confirmed_mismatch():
|
||||
original_token = settings.first_install_token
|
||||
original_confirmed = settings.first_install_token_confirmed
|
||||
|
||||
try:
|
||||
settings.first_install_token = "new-token"
|
||||
settings.first_install_token_confirmed = "old-token"
|
||||
assert settings.has_first_install_token_changed() is True
|
||||
|
||||
settings.first_install_token_confirmed = "new-token"
|
||||
assert settings.has_first_install_token_changed() is False
|
||||
|
||||
settings.first_install_token_confirmed = None
|
||||
assert settings.has_first_install_token_changed() is False
|
||||
|
||||
settings.first_install_token = None
|
||||
assert settings.has_first_install_token_changed() is False
|
||||
finally:
|
||||
settings.first_install_token = original_token
|
||||
settings.first_install_token_confirmed = original_confirmed
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_first_install_confirms_first_install_token(app):
|
||||
temp_super_user = uuid4().hex
|
||||
username = f"super_{temp_super_user[:8]}"
|
||||
original_super_user = settings.super_user
|
||||
original_first_install = settings.first_install
|
||||
original_first_install_token = settings.first_install_token
|
||||
original_first_install_token_confirmed = settings.first_install_token_confirmed
|
||||
original_confirmed_row = await get_settings_field("first_install_token_confirmed")
|
||||
|
||||
await create_account(Account(id=temp_super_user, extra=UserExtra(provider="env")))
|
||||
|
||||
try:
|
||||
settings.super_user = temp_super_user
|
||||
settings.first_install = True
|
||||
settings.first_install_token = "expected-token"
|
||||
settings.first_install_token_confirmed = None
|
||||
|
||||
response = await first_install(
|
||||
UpdateSuperuserPassword(
|
||||
username=username,
|
||||
password="secret1234",
|
||||
password_repeat="secret1234",
|
||||
first_install_token="expected-token",
|
||||
)
|
||||
)
|
||||
|
||||
assert response.status_code == 200
|
||||
assert settings.first_install is False
|
||||
assert settings.first_install_token_confirmed == "expected-token"
|
||||
|
||||
confirmed_row = await get_settings_field("first_install_token_confirmed")
|
||||
assert confirmed_row is not None
|
||||
assert confirmed_row.value == "expected-token"
|
||||
|
||||
account = await get_account(temp_super_user)
|
||||
assert account is not None
|
||||
assert account.username == username
|
||||
assert account.extra.provider == "lnbits"
|
||||
assert account.verify_password("secret1234")
|
||||
finally:
|
||||
await _restore_setting_field(
|
||||
"first_install_token_confirmed", original_confirmed_row
|
||||
)
|
||||
settings.super_user = original_super_user
|
||||
settings.first_install = original_first_install
|
||||
settings.first_install_token = original_first_install_token
|
||||
settings.first_install_token_confirmed = original_first_install_token_confirmed
|
||||
await delete_account(temp_super_user)
|
||||
|
||||
|
||||
@pytest.mark.anyio
|
||||
async def test_check_admin_settings_clears_persisted_super_user_when_token_changes(app):
|
||||
temp_super_user = uuid4().hex
|
||||
original_super_user = settings.super_user
|
||||
original_first_install = settings.first_install
|
||||
original_first_install_token = settings.first_install_token
|
||||
original_first_install_token_confirmed = settings.first_install_token_confirmed
|
||||
original_super_user_row = await get_settings_field("super_user")
|
||||
original_confirmed_row = await get_settings_field("first_install_token_confirmed")
|
||||
super_user_file = Path(settings.lnbits_data_folder) / ".super_user"
|
||||
|
||||
await create_account(
|
||||
Account(id=temp_super_user, extra=UserExtra(provider="lnbits"))
|
||||
)
|
||||
|
||||
try:
|
||||
await set_settings_field("super_user", temp_super_user)
|
||||
await set_settings_field("first_install_token_confirmed", "old-token")
|
||||
|
||||
settings.lnbits_admin_ui = True
|
||||
settings.super_user = temp_super_user
|
||||
settings.first_install = False
|
||||
settings.first_install_token = "new-token"
|
||||
settings.first_install_token_confirmed = "old-token"
|
||||
|
||||
await check_admin_settings()
|
||||
|
||||
super_user_row = await get_settings_field("super_user")
|
||||
assert super_user_row is not None
|
||||
assert super_user_row.value
|
||||
assert settings.first_install is True
|
||||
finally:
|
||||
await _restore_setting_field("super_user", original_super_user_row)
|
||||
await _restore_setting_field(
|
||||
"first_install_token_confirmed", original_confirmed_row
|
||||
)
|
||||
settings.super_user = original_super_user
|
||||
settings.first_install = original_first_install
|
||||
settings.first_install_token = original_first_install_token
|
||||
settings.first_install_token_confirmed = original_first_install_token_confirmed
|
||||
super_user_file.write_text(original_super_user)
|
||||
await delete_account(temp_super_user)
|
||||
Reference in New Issue
Block a user