Adds super user and config setup
Adds super user role to restrict settings changes. Improves the settings screen to only allow super users to make modifications. Adds a warning banner if the Castle wallet is not configured. Changes admin key to inkey for fetching settings. This fixes an issue where settings weren't accessible. Adds a validation to require the Castle wallet ID when updating settings.
This commit is contained in:
parent
29983cedb7
commit
31344607c6
3 changed files with 106 additions and 16 deletions
|
|
@ -13,6 +13,8 @@ window.app = Vue.createApp({
|
|||
currencies: [],
|
||||
settings: null,
|
||||
isAdmin: false,
|
||||
isSuperUser: false,
|
||||
castleWalletConfigured: false,
|
||||
expenseDialog: {
|
||||
show: false,
|
||||
description: '',
|
||||
|
|
@ -104,16 +106,21 @@ window.app = Vue.createApp({
|
|||
},
|
||||
async loadSettings() {
|
||||
try {
|
||||
// Try with admin key first to check settings
|
||||
const response = await LNbits.api.request(
|
||||
'GET',
|
||||
'/castle/api/v1/settings',
|
||||
this.g.user.wallets[0].adminkey
|
||||
this.g.user.wallets[0].inkey
|
||||
)
|
||||
this.settings = response.data
|
||||
this.isAdmin = true
|
||||
this.castleWalletConfigured = !!(this.settings && this.settings.castle_wallet_id)
|
||||
|
||||
// Check if user is super user by seeing if they can access admin features
|
||||
this.isSuperUser = this.g.user.super_user || false
|
||||
this.isAdmin = this.g.user.admin || this.isSuperUser
|
||||
} catch (error) {
|
||||
// Not admin or settings not available
|
||||
this.isAdmin = false
|
||||
// Settings not available
|
||||
this.castleWalletConfigured = false
|
||||
}
|
||||
},
|
||||
showSettingsDialog() {
|
||||
|
|
@ -121,6 +128,14 @@ window.app = Vue.createApp({
|
|||
this.settingsDialog.show = true
|
||||
},
|
||||
async submitSettings() {
|
||||
if (!this.settingsDialog.castleWalletId) {
|
||||
this.$q.notify({
|
||||
type: 'warning',
|
||||
message: 'Castle Wallet ID is required'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
this.settingsDialog.loading = true
|
||||
try {
|
||||
await LNbits.api.request(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue