Reset wallet keys (#2929)
This commit is contained in:
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -505,5 +505,8 @@ window.localisation.en = {
|
||||
payments_balance_chart: 'Balance Chart',
|
||||
payments_wallets_chart: 'Wallets Chart',
|
||||
payments_balance_in_out_chart: 'Balance In/Out Chart',
|
||||
payments_count_in_out_chart: 'Count In/Out Chart'
|
||||
payments_count_in_out_chart: 'Count In/Out Chart',
|
||||
reset_wallet_keys: 'Reset Keys',
|
||||
reset_wallet_keys_desc:
|
||||
'Reset the API keys for this wallet. This will invalidate the current keys and generate new ones.'
|
||||
}
|
||||
|
||||
@@ -132,15 +132,20 @@ window.LNbits = {
|
||||
name: name
|
||||
})
|
||||
},
|
||||
deleteWallet(wallet) {
|
||||
return this.request('delete', '/api/v1/wallet', wallet.adminkey).then(
|
||||
_ => {
|
||||
let url = new URL(window.location.href)
|
||||
url.searchParams.delete('wal')
|
||||
window.location = url
|
||||
resetWalletKeys(wallet) {
|
||||
return this.request('put', `/api/v1/wallet/reset/${wallet.id}`).then(
|
||||
res => {
|
||||
return res.data
|
||||
}
|
||||
)
|
||||
},
|
||||
deleteWallet(wallet) {
|
||||
return this.request('delete', `/api/v1/wallet/${wallet.id}`).then(_ => {
|
||||
let url = new URL(window.location.href)
|
||||
url.searchParams.delete('wal')
|
||||
window.location = url
|
||||
})
|
||||
},
|
||||
getPayments(wallet, params) {
|
||||
return this.request(
|
||||
'get',
|
||||
|
||||
@@ -564,6 +564,40 @@ window.WalletPageLogic = {
|
||||
}
|
||||
})
|
||||
},
|
||||
resetKeys() {
|
||||
LNbits.utils
|
||||
.confirmDialog('Are you sure you want to reset your API keys?')
|
||||
.onOk(() => {
|
||||
LNbits.api
|
||||
.resetWalletKeys(this.g.wallet)
|
||||
.then(response => {
|
||||
const {id, adminkey, inkey} = response
|
||||
this.g.wallet = {
|
||||
...this.g.wallet,
|
||||
inkey,
|
||||
adminkey
|
||||
}
|
||||
const walletIndex = this.g.user.wallets.findIndex(
|
||||
wallet => wallet.id === id
|
||||
)
|
||||
if (walletIndex !== -1) {
|
||||
this.g.user.wallets[walletIndex] = {
|
||||
...this.g.user.wallets[walletIndex],
|
||||
inkey,
|
||||
adminkey
|
||||
}
|
||||
}
|
||||
Quasar.Notify.create({
|
||||
timeout: 3500,
|
||||
type: 'positive',
|
||||
message: 'API keys reset!'
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
LNbits.utils.notifyApiError(err)
|
||||
})
|
||||
})
|
||||
},
|
||||
updateWallet(data) {
|
||||
LNbits.api
|
||||
.request('PATCH', '/api/v1/wallet', this.g.wallet.adminkey, data)
|
||||
|
||||
Reference in New Issue
Block a user