feat(admin): archive users and their profiles permanently
All checks were successful
Build and Release FEDEO / verify (push) Successful in 1m5s
Build and Release FEDEO / build-and-release (push) Successful in 6m53s

This commit is contained in:
2026-10-15 14:22:12 +02:00
parent 5dc9e686fc
commit 4ffafef3f1
26 changed files with 519 additions and 75 deletions

View File

@@ -1,5 +1,5 @@
import { FastifyInstance } from "fastify"
import { eq, and } from "drizzle-orm"
import { eq, and, isNull } from "drizzle-orm"
import {
authUsers,
@@ -83,7 +83,8 @@ export default async function userRoutes(server: FastifyInstance) {
.where(
and(
eq(authProfiles.user_id, id),
eq(authProfiles.tenant_id, req.user.tenant_id)
eq(authProfiles.tenant_id, req.user.tenant_id),
isNull(authProfiles.archived_at)
)
)
@@ -99,6 +100,7 @@ export default async function userRoutes(server: FastifyInstance) {
}
const updateData: any = { ...data }
for (const key of ["archived_at", "user_id", "tenant_id", "id"]) delete updateData[key]
// bekannte Date-Felder prüfen
if (data.entry_date !== undefined)
@@ -116,9 +118,10 @@ export default async function userRoutes(server: FastifyInstance) {
const [updatedProfile] = await server.db
.update(authProfiles)
.set(updateData)
.where(eq(authProfiles.id, profile.id))
.where(and(eq(authProfiles.id, profile.id), isNull(authProfiles.archived_at)))
.returning()
if (!updatedProfile) return reply.code(404).send({ error: "Profile not found in tenant" })
return { profile: updatedProfile }
} catch (err: any) {