Use ctx.identity instead of passing it as param
This commit is contained in:
parent
f8959aacb0
commit
4f2696ed32
|
@ -177,7 +177,7 @@ export const destroy = async (ctx: any) => {
|
||||||
ctx.throw(400, "Unable to delete self.")
|
ctx.throw(400, "Unable to delete self.")
|
||||||
}
|
}
|
||||||
|
|
||||||
await userSdk.destroy(id, ctx.user)
|
await userSdk.destroy(id)
|
||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
message: `User ${id} deleted.`,
|
message: `User ${id} deleted.`,
|
||||||
|
|
|
@ -6,7 +6,7 @@ export const initPro = async () => {
|
||||||
scimUserServiceConfig: {
|
scimUserServiceConfig: {
|
||||||
functions: {
|
functions: {
|
||||||
saveUser: userSdk.save,
|
saveUser: userSdk.save,
|
||||||
removeUser: (id: string) => userSdk.destroy(id, undefined),
|
removeUser: (id: string) => userSdk.destroy(id),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
@ -15,6 +15,7 @@ import {
|
||||||
utils,
|
utils,
|
||||||
ViewName,
|
ViewName,
|
||||||
env as coreEnv,
|
env as coreEnv,
|
||||||
|
context,
|
||||||
} from "@budibase/backend-core"
|
} from "@budibase/backend-core"
|
||||||
import {
|
import {
|
||||||
AccountMetadata,
|
AccountMetadata,
|
||||||
|
@ -537,7 +538,7 @@ export const bulkDelete = async (
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
export const destroy = async (id: string, currentUser: any) => {
|
export const destroy = async (id: string) => {
|
||||||
const db = tenancy.getGlobalDB()
|
const db = tenancy.getGlobalDB()
|
||||||
const dbUser = (await db.get(id)) as User
|
const dbUser = (await db.get(id)) as User
|
||||||
const userId = dbUser._id as string
|
const userId = dbUser._id as string
|
||||||
|
@ -547,7 +548,7 @@ export const destroy = async (id: string, currentUser: any) => {
|
||||||
const email = dbUser.email
|
const email = dbUser.email
|
||||||
const account = await accounts.getAccount(email)
|
const account = await accounts.getAccount(email)
|
||||||
if (account) {
|
if (account) {
|
||||||
if (email === currentUser.email) {
|
if (dbUser.userId === context.getIdentity()!._id) {
|
||||||
throw new HTTPError('Please visit "Account" to delete this user', 400)
|
throw new HTTPError('Please visit "Account" to delete this user', 400)
|
||||||
} else {
|
} else {
|
||||||
throw new HTTPError("Account holder cannot be deleted", 400)
|
throw new HTTPError("Account holder cannot be deleted", 400)
|
||||||
|
|
Loading…
Reference in New Issue