diff --git a/.env.example b/.env.example index 4192f82ec..f0e21aa86 100644 --- a/.env.example +++ b/.env.example @@ -4,8 +4,8 @@ PORT=5000 DEBUG=false LNBITS_ADMIN_USERS="" # User IDs seperated by comma -LNBITS_ADMIN_EXTENSIONS="ngrok" # Extensions only admin can access -LNBITS_ADMIN_UI=false # Enable Admin GUI, available for the first user in LNBITS_ADMIN_USERS +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 if available LNBITS_ALLOWED_USERS="" # Restricts access, User IDs seperated by comma diff --git a/lnbits/config.py b/lnbits/config.py index b2fbfff12..3ce51c3cb 100644 --- a/lnbits/config.py +++ b/lnbits/config.py @@ -19,6 +19,7 @@ def list_parse_fallback(v): return v.replace(' ','').split(',') class Settings(BaseSettings): + admin_ui: bool = Field(default=True, env="LNBITS_ADMIN_UI") # 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") @@ -37,7 +38,7 @@ class Settings(BaseSettings): 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") 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") # .env env: Optional[str] diff --git a/lnbits/extensions/admin/README.md b/lnbits/extensions/admin/README.md index 277294592..6cf073a11 100644 --- a/lnbits/extensions/admin/README.md +++ b/lnbits/extensions/admin/README.md @@ -1,11 +1,12 @@ -
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"
+## 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.
diff --git a/lnbits/extensions/admin/migrations.py b/lnbits/extensions/admin/migrations.py
index 574f772d1..0e22e6677 100644
--- a/lnbits/extensions/admin/migrations.py
+++ b/lnbits/extensions/admin/migrations.py
@@ -6,9 +6,22 @@ from lnbits.config import conf
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):
# users/server
- user = conf.admin_users[0]
+ user = await get_admin_user()
admin_users = ",".join(conf.admin_users)
allowed_users = ",".join(conf.allowed_users)
admin_ext = ",".join(conf.admin_ext)