fix: accept soft deleted wallets (#3179)
This commit is contained in:
parent
27fd510142
commit
63e728710d
5 changed files with 74 additions and 15 deletions
|
|
@ -15,19 +15,36 @@
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="activeWallet.show">
|
<div v-else-if="activeWallet.show">
|
||||||
<div class="row q-mb-lg">
|
<div class="row q-col-gutter-md q-mb-md">
|
||||||
<div class="col">
|
<div class="col-12">
|
||||||
<q-btn
|
<q-card>
|
||||||
icon="arrow_back_ios"
|
<div class="q-pa-sm">
|
||||||
@click="backToUsersPage()"
|
<div class="row">
|
||||||
:label="$t('back')"
|
<div class="q-pa-xs">
|
||||||
></q-btn>
|
<q-btn
|
||||||
<q-btn
|
icon="arrow_back_ios"
|
||||||
@click="createWalletDialog.show = true"
|
@click="backToUsersPage()"
|
||||||
:label="$t('create_new_wallet')"
|
:label="$t('back')"
|
||||||
color="primary"
|
></q-btn>
|
||||||
class="q-ml-md"
|
</div>
|
||||||
></q-btn>
|
<div class="q-pa-xs">
|
||||||
|
<q-btn
|
||||||
|
@click="createWalletDialog.show = true"
|
||||||
|
:label="$t('create_new_wallet')"
|
||||||
|
color="primary"
|
||||||
|
></q-btn>
|
||||||
|
</div>
|
||||||
|
<div class="q-pa-xs">
|
||||||
|
<q-btn
|
||||||
|
@click="deleteAllUserWallets(activeWallet.userId)"
|
||||||
|
:label="$t('delete_all_wallets')"
|
||||||
|
icon="delete"
|
||||||
|
color="negative"
|
||||||
|
></q-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<q-card class="q-pa-md">
|
<q-card class="q-pa-md">
|
||||||
|
|
|
||||||
|
|
@ -148,7 +148,7 @@ async def api_update_user(
|
||||||
async def api_users_delete_user(
|
async def api_users_delete_user(
|
||||||
user_id: str, user: User = Depends(check_admin)
|
user_id: str, user: User = Depends(check_admin)
|
||||||
) -> SimpleStatus:
|
) -> SimpleStatus:
|
||||||
wallets = await get_wallets(user_id)
|
wallets = await get_wallets(user_id, deleted=False)
|
||||||
if len(wallets) > 0:
|
if len(wallets) > 0:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.BAD_REQUEST,
|
status_code=HTTPStatus.BAD_REQUEST,
|
||||||
|
|
@ -257,6 +257,28 @@ async def api_users_undelete_user_wallet(user_id: str, wallet: str) -> SimpleSta
|
||||||
return SimpleStatus(success=True, message="Wallet is already active.")
|
return SimpleStatus(success=True, message="Wallet is already active.")
|
||||||
|
|
||||||
|
|
||||||
|
@users_router.delete(
|
||||||
|
"/user/{user_id}/wallets",
|
||||||
|
name="Delete all wallets for user",
|
||||||
|
summary="Soft delete (only sets a flag) all user wallets.",
|
||||||
|
)
|
||||||
|
async def api_users_delete_all_user_wallet(user_id: str) -> SimpleStatus:
|
||||||
|
if user_id == settings.super_user:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=HTTPStatus.BAD_REQUEST,
|
||||||
|
detail="Action not allowed.",
|
||||||
|
)
|
||||||
|
|
||||||
|
wallets = await get_wallets(user_id, deleted=False)
|
||||||
|
for wallet in wallets:
|
||||||
|
await delete_wallet(user_id=user_id, wallet_id=wallet.id)
|
||||||
|
|
||||||
|
return SimpleStatus(
|
||||||
|
success=True,
|
||||||
|
message=f"Deleted '{len(wallets)}' wallets. ",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@users_router.delete(
|
@users_router.delete(
|
||||||
"/user/{user_id}/wallet/{wallet}",
|
"/user/{user_id}/wallet/{wallet}",
|
||||||
name="Delete wallet by id",
|
name="Delete wallet by id",
|
||||||
|
|
|
||||||
2
lnbits/static/bundle.min.js
vendored
2
lnbits/static/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -308,6 +308,9 @@ window.localisation.en = {
|
||||||
login_with_user_id: 'Login with user ID',
|
login_with_user_id: 'Login with user ID',
|
||||||
or: 'or',
|
or: 'or',
|
||||||
create_new_wallet: 'Create New Wallet',
|
create_new_wallet: 'Create New Wallet',
|
||||||
|
delete_all_wallets: 'Delete All Wallets',
|
||||||
|
confirm_delete_all_wallets:
|
||||||
|
'Are you sure you want to delete ALL wallets for this user?',
|
||||||
login_to_account: 'Login to your account',
|
login_to_account: 'Login to your account',
|
||||||
create_account: 'Create account',
|
create_account: 'Create account',
|
||||||
account_settings: 'Account Settings',
|
account_settings: 'Account Settings',
|
||||||
|
|
|
||||||
|
|
@ -312,6 +312,23 @@ window.UsersPageLogic = {
|
||||||
.catch(LNbits.utils.notifyApiError)
|
.catch(LNbits.utils.notifyApiError)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
deleteAllUserWallets(userId) {
|
||||||
|
LNbits.utils
|
||||||
|
.confirmDialog(this.$t('confirm_delete_all_wallets'))
|
||||||
|
.onOk(() => {
|
||||||
|
LNbits.api
|
||||||
|
.request('DELETE', `/users/api/v1/user/${userId}/wallets`)
|
||||||
|
.then(response => {
|
||||||
|
Quasar.Notify.create({
|
||||||
|
type: 'positive',
|
||||||
|
message: response.data.message,
|
||||||
|
icon: null
|
||||||
|
})
|
||||||
|
this.fetchWallets(userId)
|
||||||
|
})
|
||||||
|
.catch(LNbits.utils.notifyApiError)
|
||||||
|
})
|
||||||
|
},
|
||||||
copyWalletLink(walletId) {
|
copyWalletLink(walletId) {
|
||||||
const url = `${window.location.origin}/wallet?usr=${this.activeWallet.userId}&wal=${walletId}`
|
const url = `${window.location.origin}/wallet?usr=${this.activeWallet.userId}&wal=${walletId}`
|
||||||
this.copyText(url)
|
this.copyText(url)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue