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