mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-19 20:14:59 +02:00
Merge branch 'usermanagerupdate'
This commit is contained in:
@@ -17,7 +17,11 @@ from .models import Users, Wallets
|
||||
|
||||
|
||||
async def create_usermanager_user(
|
||||
user_name: str, wallet_name: str, admin_id: str
|
||||
user_name: str,
|
||||
wallet_name: str,
|
||||
admin_id: str,
|
||||
email: Optional[str] = None,
|
||||
password: Optional[str] = None,
|
||||
) -> Users:
|
||||
account = await create_account()
|
||||
user = await get_user(account.id)
|
||||
@@ -27,10 +31,10 @@ async def create_usermanager_user(
|
||||
|
||||
await db.execute(
|
||||
"""
|
||||
INSERT INTO users (id, name, admin)
|
||||
VALUES (?, ?, ?)
|
||||
INSERT INTO users (id, name, admin, email, password)
|
||||
VALUES (?, ?, ?, ?, ?)
|
||||
""",
|
||||
(user.id, user_name, admin_id),
|
||||
(user.id, user_name, admin_id, email, password),
|
||||
)
|
||||
|
||||
await db.execute(
|
||||
|
@@ -114,7 +114,8 @@
|
||||
</h5>
|
||||
<code
|
||||
>{"admin_id": <string>, "user_name": <string>,
|
||||
"wallet_name": <string>}</code
|
||||
"wallet_name": <string>,"email": <Optional string>
|
||||
,"password": <Optional string>}</code
|
||||
>
|
||||
<h5 class="text-caption q-mt-sm q-mb-none">
|
||||
Returns 201 CREATED (application/json)
|
||||
@@ -128,7 +129,8 @@
|
||||
<code
|
||||
>curl -X POST {{ request.url_root }}api/v1/users -d '{"admin_id": "{{
|
||||
g.user.id }}", "wallet_name": <string>, "user_name":
|
||||
<string>}' -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" -H
|
||||
<string>, "email": <Optional string>, "password": <
|
||||
Optional string>}' -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" -H
|
||||
"Content-type: application/json"
|
||||
</code>
|
||||
</q-card-section>
|
||||
|
@@ -157,6 +157,18 @@
|
||||
v-model.trim="userDialog.data.walname"
|
||||
label="Initial wallet name"
|
||||
></q-input>
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
v-model.trim="userDialog.data.email"
|
||||
label="Email"
|
||||
></q-input>
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
v-model.trim="userDialog.data.password"
|
||||
label="Password"
|
||||
></q-input>
|
||||
|
||||
<q-btn
|
||||
unelevated
|
||||
@@ -224,7 +236,14 @@
|
||||
usersTable: {
|
||||
columns: [
|
||||
{name: 'id', align: 'left', label: 'ID', field: 'id'},
|
||||
{name: 'name', align: 'left', label: 'Username', field: 'name'}
|
||||
{name: 'name', align: 'left', label: 'Username', field: 'name'},
|
||||
{name: 'email', align: 'left', label: 'Email', field: 'email'},
|
||||
{
|
||||
name: 'password',
|
||||
align: 'left',
|
||||
label: 'Password',
|
||||
field: 'password'
|
||||
}
|
||||
],
|
||||
pagination: {
|
||||
rowsPerPage: 10
|
||||
@@ -299,7 +318,9 @@
|
||||
var data = {
|
||||
admin_id: this.g.user.id,
|
||||
user_name: this.userDialog.data.usrname,
|
||||
wallet_name: this.userDialog.data.walname
|
||||
wallet_name: this.userDialog.data.walname,
|
||||
email: this.userDialog.data.email,
|
||||
password: this.userDialog.data.password
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -33,19 +33,29 @@ async def api_usermanager_users():
|
||||
)
|
||||
|
||||
|
||||
@usermanager_ext.route("/api/v1/users/<user_id>", methods=["GET"])
|
||||
@api_check_wallet_key(key_type="invoice")
|
||||
async def api_usermanager_user(user_id):
|
||||
user = await get_usermanager_user(user_id)
|
||||
return (
|
||||
jsonify(user._asdict()),
|
||||
HTTPStatus.OK,
|
||||
)
|
||||
|
||||
|
||||
@usermanager_ext.route("/api/v1/users", methods=["POST"])
|
||||
@api_check_wallet_key(key_type="invoice")
|
||||
@api_validate_post_request(
|
||||
schema={
|
||||
"admin_id": {"type": "string", "empty": False, "required": True},
|
||||
"user_name": {"type": "string", "empty": False, "required": True},
|
||||
"wallet_name": {"type": "string", "empty": False, "required": True},
|
||||
"admin_id": {"type": "string", "empty": False, "required": True},
|
||||
"email": {"type": "string", "required": False},
|
||||
"password": {"type": "string", "required": False},
|
||||
}
|
||||
)
|
||||
async def api_usermanager_users_create():
|
||||
user = await create_usermanager_user(
|
||||
g.data["user_name"], g.data["wallet_name"], g.data["admin_id"]
|
||||
)
|
||||
user = await create_usermanager_user(**g.data)
|
||||
return jsonify(user._asdict()), HTTPStatus.CREATED
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user