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