mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-27 12:26:19 +02:00
create first user on fresh install
This commit is contained in:
@@ -4,8 +4,8 @@ PORT=5000
|
|||||||
DEBUG=false
|
DEBUG=false
|
||||||
|
|
||||||
LNBITS_ADMIN_USERS="" # User IDs seperated by comma
|
LNBITS_ADMIN_USERS="" # User IDs seperated by comma
|
||||||
LNBITS_ADMIN_EXTENSIONS="ngrok" # Extensions only admin can access
|
LNBITS_ADMIN_EXTENSIONS="ngrok, admin" # Extensions only admin can access
|
||||||
LNBITS_ADMIN_UI=false # Enable Admin GUI, available for the first user in LNBITS_ADMIN_USERS
|
LNBITS_ADMIN_UI=false # Enable Admin GUI, available for the first user in LNBITS_ADMIN_USERS if available
|
||||||
|
|
||||||
LNBITS_ALLOWED_USERS="" # Restricts access, User IDs seperated by comma
|
LNBITS_ALLOWED_USERS="" # Restricts access, User IDs seperated by comma
|
||||||
|
|
||||||
|
@@ -19,6 +19,7 @@ def list_parse_fallback(v):
|
|||||||
return v.replace(' ','').split(',')
|
return v.replace(' ','').split(',')
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
|
admin_ui: bool = Field(default=True, env="LNBITS_ADMIN_UI")
|
||||||
# users
|
# users
|
||||||
admin_users: List[str] = Field(default_factory=list, env="LNBITS_ADMIN_USERS")
|
admin_users: List[str] = Field(default_factory=list, env="LNBITS_ADMIN_USERS")
|
||||||
allowed_users: List[str] = Field(default_factory=list, env="LNBITS_ALLOWED_USERS")
|
allowed_users: List[str] = Field(default_factory=list, env="LNBITS_ALLOWED_USERS")
|
||||||
@@ -37,7 +38,7 @@ class Settings(BaseSettings):
|
|||||||
site_tagline: str = Field(default="free and open-source lightning wallet", env="LNBITS_SITE_TAGLINE")
|
site_tagline: str = Field(default="free and open-source lightning wallet", env="LNBITS_SITE_TAGLINE")
|
||||||
site_description: str = Field(default=None, env="LNBITS_SITE_DESCRIPTION")
|
site_description: str = Field(default=None, env="LNBITS_SITE_DESCRIPTION")
|
||||||
default_wallet_name: str = Field(default="LNbits wallet", env="LNBITS_DEFAULT_WALLET_NAME")
|
default_wallet_name: str = Field(default="LNbits wallet", env="LNBITS_DEFAULT_WALLET_NAME")
|
||||||
theme: List[str] = Field(default="classic, flamingo, mint, salvador, monochrome, autumn", env="LNBITS_THEME_OPTIONS")
|
theme: List[str] = Field(default=["classic, flamingo, mint, salvador, monochrome, autumn"], env="LNBITS_THEME_OPTIONS")
|
||||||
ad_space: List[str] = Field(default_factory=list, env="LNBITS_AD_SPACE")
|
ad_space: List[str] = Field(default_factory=list, env="LNBITS_AD_SPACE")
|
||||||
# .env
|
# .env
|
||||||
env: Optional[str]
|
env: Optional[str]
|
||||||
|
@@ -1,11 +1,12 @@
|
|||||||
<h1>Example Extension</h1>
|
# Admin Extension
|
||||||
<h2>*tagline*</h2>
|
|
||||||
This is an example extension to help you organise and build you own.
|
|
||||||
|
|
||||||
Try to include an image
|
## Dashboard to manage LNbits from the UI
|
||||||
<img src="https://i.imgur.com/9i4xcQB.png">
|
|
||||||
|
|
||||||
|
With AdminUI you can manage your LNbits from the UI
|
||||||
|
|
||||||
<h2>If your extension has API endpoints, include useful ones here</h2>
|

|
||||||
|
|
||||||
<code>curl -H "Content-type: application/json" -X POST https://YOUR-LNBITS/YOUR-EXTENSION/api/v1/EXAMPLE -d '{"amount":"100","memo":"example"}' -H "X-Api-Key: YOUR_WALLET-ADMIN/INVOICE-KEY"</code>
|
## Before you start
|
||||||
|
|
||||||
|
**This extension doesn't discard the need for the `.env` file!**
|
||||||
|
In the .env file, set the `LNBITS_ADMIN_USERS` variable to include at least your user id.
|
||||||
|
@@ -6,9 +6,22 @@ from lnbits.config import conf
|
|||||||
from lnbits.helpers import urlsafe_short_hash
|
from lnbits.helpers import urlsafe_short_hash
|
||||||
|
|
||||||
|
|
||||||
|
async def get_admin_user():
|
||||||
|
if(conf.admin_users[0]):
|
||||||
|
return conf.admin_users[0]
|
||||||
|
from lnbits.core.crud import create_account, get_user
|
||||||
|
print("Seems like there's no admin users yet. Let's create an account for you!")
|
||||||
|
account = await create_account()
|
||||||
|
user = account.id
|
||||||
|
assert user, "Newly created user couldn't be retrieved"
|
||||||
|
print(f"Your newly created account/user id is: {user}. This will be the Super Admin user.")
|
||||||
|
return user
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def m001_create_admin_table(db):
|
async def m001_create_admin_table(db):
|
||||||
# users/server
|
# users/server
|
||||||
user = conf.admin_users[0]
|
user = await get_admin_user()
|
||||||
admin_users = ",".join(conf.admin_users)
|
admin_users = ",".join(conf.admin_users)
|
||||||
allowed_users = ",".join(conf.allowed_users)
|
allowed_users = ",".join(conf.allowed_users)
|
||||||
admin_ext = ",".join(conf.admin_ext)
|
admin_ext = ",".join(conf.admin_ext)
|
||||||
|
Reference in New Issue
Block a user