chore: Add emailed confirmation code to account deletion (#3873)

* wip

* tests
This commit is contained in:
Tom Moor
2022-07-31 18:59:40 +01:00
committed by GitHub
parent f9d9a82e47
commit cb9773ad85
8 changed files with 238 additions and 69 deletions

View File

@@ -215,6 +215,22 @@ class User extends ParanoidModel {
return stringToColor(this.id);
}
/**
* Returns a code that can be used to delete this user account. The code will
* be rotated when the user signs out.
*
* @returns The deletion code.
*/
get deleteConfirmationCode() {
return crypto
.createHash("md5")
.update(this.jwtSecret)
.digest("hex")
.replace(/[l1IoO0]/gi, "")
.slice(0, 8)
.toUpperCase();
}
// instance methods
/**
@@ -550,7 +566,7 @@ class User extends ParanoidModel {
suspendedCount: string;
viewerCount: string;
count: string;
} = results as any;
} = results;
return {
active: parseInt(counts.activeCount),