feat: Add team deletion flow for cloud-hosted (#5717)

This commit is contained in:
Tom Moor
2023-08-21 20:24:46 -04:00
committed by GitHub
parent 5c07694f6b
commit 418d3305b2
26 changed files with 461 additions and 71 deletions

View File

@@ -28,7 +28,6 @@ import {
assertSort,
assertPresent,
assertArray,
assertUuid,
} from "@server/validation";
import pagination from "../middlewares/pagination";
import * as T from "./schema";
@@ -449,13 +448,15 @@ router.post(
"users.delete",
rateLimiter(RateLimiterStrategy.TenPerHour),
auth(),
async (ctx: APIContext) => {
const { id, code = "" } = ctx.request.body;
validate(T.UsersDeleteSchema),
transaction(),
async (ctx: APIContext<T.UsersDeleteSchemaReq>) => {
const { transaction } = ctx.state;
const { id, code } = ctx.request.body;
const actor = ctx.state.auth.user;
let user: User;
if (id) {
assertUuid(id, "id must be a UUID");
user = await User.findByPk(id, {
rejectOnEmpty: true,
});
@@ -478,6 +479,7 @@ router.post(
user,
actor,
ip: ctx.request.ip,
transaction,
});
ctx.body = {