feat(admin): archive users and their profiles permanently
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
||||
tenants
|
||||
} from "../../../db/schema"
|
||||
|
||||
import {and, eq, inArray} from "drizzle-orm"
|
||||
import {and, eq, inArray, isNull} from "drizzle-orm"
|
||||
import { enrichProfilesWithBranches } from "../../utils/profileBranches"
|
||||
import { enrichProfilesWithTeams } from "../../utils/profileTeams"
|
||||
|
||||
@@ -52,7 +52,7 @@ export default async function tenantRoutesInternal(server: FastifyInstance) {
|
||||
const users = await server.db
|
||||
.select()
|
||||
.from(authUsers)
|
||||
.where(inArray(authUsers.id, userIds))
|
||||
.where(and(inArray(authUsers.id, userIds), isNull(authUsers.archived_at)))
|
||||
|
||||
// 3) auth_profiles pro Tenant laden
|
||||
const profileRows = await server.db
|
||||
@@ -61,7 +61,9 @@ export default async function tenantRoutesInternal(server: FastifyInstance) {
|
||||
.where(
|
||||
and(
|
||||
eq(authProfiles.tenant_id, tenantId),
|
||||
inArray(authProfiles.user_id, userIds)
|
||||
inArray(authProfiles.user_id, userIds),
|
||||
eq(authProfiles.active, true),
|
||||
isNull(authProfiles.archived_at)
|
||||
))
|
||||
const profilesWithBranches = await enrichProfilesWithBranches(server, profileRows)
|
||||
const profiles = await enrichProfilesWithTeams(server, profilesWithBranches)
|
||||
@@ -98,7 +100,7 @@ export default async function tenantRoutesInternal(server: FastifyInstance) {
|
||||
const profileRows = await server.db
|
||||
.select()
|
||||
.from(authProfiles)
|
||||
.where(eq(authProfiles.tenant_id, tenantId))
|
||||
.where(and(eq(authProfiles.tenant_id, tenantId), eq(authProfiles.active, true), isNull(authProfiles.archived_at)))
|
||||
|
||||
const profilesWithBranches = await enrichProfilesWithBranches(server, profileRows)
|
||||
return await enrichProfilesWithTeams(server, profilesWithBranches)
|
||||
|
||||
Reference in New Issue
Block a user