Do not allow deleting ad users

This commit is contained in:
Adria Navarro 2024-02-27 16:25:08 +01:00
parent e8200570ec
commit 7fb32c2f57
1 changed files with 9 additions and 4 deletions

View File

@ -37,7 +37,6 @@
import { Constants, Utils, fetchData } from "@budibase/frontend-core"
import { API } from "api"
import { OnboardingType } from "constants"
import ScimInfo from "../_components/SCIMInfo.svelte"
import { sdk } from "@budibase/shared-core"
const fetch = fetchData({
@ -248,19 +247,25 @@
}
}
const deleteRows = async () => {
const deleteUsers = async () => {
try {
let ids = selectedRows.map(user => user._id)
if (ids.includes(get(auth).user._id)) {
notifications.error("You cannot delete yourself")
return
}
if (selectedRows.some(u => u.scimInfo?.isSync)) {
notifications.error("You cannot remove users created via your AD")
return
}
await users.bulkDelete(ids)
notifications.success(`Successfully deleted ${selectedRows.length} rows`)
selectedRows = []
await fetch.refresh()
} catch (error) {
notifications.error("Error deleting rows")
notifications.error("Error deleting users")
}
}
@ -329,7 +334,7 @@
item="user"
on:updaterows
{selectedRows}
{deleteRows}
deleteRows={deleteUsers}
/>
{/if}
</div>