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

@@ -1,3 +1,4 @@
import crypto from "crypto";
import fs from "fs";
import path from "path";
import { URL } from "url";
@@ -176,6 +177,22 @@ class Team extends ParanoidModel {
return url.href.replace(/\/$/, "");
}
/**
* Returns a code that can be used to delete the user's team. The code will
* be rotated when the user signs out.
*
* @returns The deletion code.
*/
public getDeleteConfirmationCode(user: User) {
return crypto
.createHash("md5")
.update(`${this.id}${user.jwtSecret}`)
.digest("hex")
.replace(/[l1IoO0]/gi, "")
.slice(0, 8)
.toUpperCase();
}
/**
* Preferences that decide behavior for the team.
*