create first user on fresh install
This commit is contained in:
parent
b0ac6d2cc6
commit
b0f9c82e1b
|
@ -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
|
||||
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
<h1>Example Extension</h1>
|
||||
<h2>*tagline*</h2>
|
||||
This is an example extension to help you organise and build you own.
|
||||
# Admin Extension
|
||||
|
||||
Try to include an image
|
||||
<img src="https://i.imgur.com/9i4xcQB.png">
|
||||
## Dashboard to manage LNbits from the UI
|
||||
|
||||
With AdminUI you can manage your LNbits from the UI
|
||||
|
||||
<h2>If your extension has API endpoints, include useful ones here</h2>
|
||||
![AdminUI](https://i.imgur.com/BIyLkyG.png)
|
||||
|
||||
<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
|
||||
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user