fix: fetch wallets for admin (#51)
This commit is contained in:
parent
d0f1089f08
commit
5a078f2bfc
2 changed files with 14 additions and 23 deletions
|
|
@ -476,11 +476,7 @@
|
||||||
getRelays: function () {
|
getRelays: function () {
|
||||||
var self = this
|
var self = this
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request(
|
.request('GET', '/nostrclient/api/v1/relays')
|
||||||
'GET',
|
|
||||||
'/nostrclient/api/v1/relays?usr=' + this.g.user.id,
|
|
||||||
this.g.user.wallets[0].adminkey
|
|
||||||
)
|
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
response.data.map(maplrelays)
|
response.data.map(maplrelays)
|
||||||
|
|
@ -508,12 +504,9 @@
|
||||||
console.log('ADD RELAY ' + this.relayToAdd)
|
console.log('ADD RELAY ' + this.relayToAdd)
|
||||||
let that = this
|
let that = this
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request(
|
.request('POST', '/nostrclient/api/v1/relay', null, {
|
||||||
'POST',
|
url: this.relayToAdd
|
||||||
'/nostrclient/api/v1/relay?usr=' + this.g.user.id,
|
})
|
||||||
this.g.user.wallets[0].adminkey,
|
|
||||||
{url: this.relayToAdd}
|
|
||||||
)
|
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
console.log('response:', response)
|
console.log('response:', response)
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
|
|
@ -540,12 +533,7 @@
|
||||||
},
|
},
|
||||||
deleteRelay(url) {
|
deleteRelay(url) {
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request(
|
.request('DELETE', '/nostrclient/api/v1/relay', null, {url: url})
|
||||||
'DELETE',
|
|
||||||
'/nostrclient/api/v1/relay?usr=' + this.g.user.id,
|
|
||||||
this.g.user.wallets[0].adminkey,
|
|
||||||
{url: url}
|
|
||||||
)
|
|
||||||
.then(response => {
|
.then(response => {
|
||||||
const relayIndex = this.nostrrelayLinks.indexOf(r => r.url === url)
|
const relayIndex = this.nostrrelayLinks.indexOf(r => r.url === url)
|
||||||
if (relayIndex !== -1) {
|
if (relayIndex !== -1) {
|
||||||
|
|
@ -561,8 +549,7 @@
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'GET',
|
'GET',
|
||||||
'/nostrclient/api/v1/config',
|
'/nostrclient/api/v1/config'
|
||||||
this.g.user.wallets[0].adminkey
|
|
||||||
)
|
)
|
||||||
this.config.data = data
|
this.config.data = data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
@ -574,7 +561,7 @@
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'PUT',
|
'PUT',
|
||||||
'/nostrclient/api/v1/config',
|
'/nostrclient/api/v1/config',
|
||||||
this.g.user.wallets[0].adminkey,
|
null,
|
||||||
this.config.data
|
this.config.data
|
||||||
)
|
)
|
||||||
this.config.data = data
|
this.config.data = data
|
||||||
|
|
@ -623,7 +610,7 @@
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'PUT',
|
'PUT',
|
||||||
'/nostrclient/api/v1/relay/test',
|
'/nostrclient/api/v1/relay/test',
|
||||||
this.g.user.wallets[0].adminkey,
|
null,
|
||||||
{
|
{
|
||||||
sender_private_key: this.testData.senderPrivateKey,
|
sender_private_key: this.testData.senderPrivateKey,
|
||||||
reciever_public_key: this.testData.recieverPublicKey,
|
reciever_public_key: this.testData.recieverPublicKey,
|
||||||
|
|
|
||||||
8
views.py
8
views.py
|
|
@ -1,6 +1,7 @@
|
||||||
from fastapi import APIRouter, Depends, Request
|
from fastapi import APIRouter, Depends, Request
|
||||||
from fastapi.responses import HTMLResponse
|
from fastapi.responses import HTMLResponse
|
||||||
from lnbits.core.models import User
|
from lnbits.core.crud.users import get_user_from_account
|
||||||
|
from lnbits.core.models.users import Account
|
||||||
from lnbits.decorators import check_admin
|
from lnbits.decorators import check_admin
|
||||||
from lnbits.helpers import template_renderer
|
from lnbits.helpers import template_renderer
|
||||||
|
|
||||||
|
|
@ -12,7 +13,10 @@ def nostr_renderer():
|
||||||
|
|
||||||
|
|
||||||
@nostrclient_generic_router.get("/", response_class=HTMLResponse)
|
@nostrclient_generic_router.get("/", response_class=HTMLResponse)
|
||||||
async def index(request: Request, user: User = Depends(check_admin)):
|
async def index(request: Request, account: Account = Depends(check_admin)):
|
||||||
|
user = await get_user_from_account(account)
|
||||||
|
if not user:
|
||||||
|
return HTMLResponse("No user found", status_code=404)
|
||||||
return nostr_renderer().TemplateResponse(
|
return nostr_renderer().TemplateResponse(
|
||||||
"nostrclient/index.html", {"request": request, "user": user.json()}
|
"nostrclient/index.html", {"request": request, "user": user.json()}
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue