Added PNID.scrub method to remove personal information

This commit is contained in:
Jonathan Barrow
2023-04-29 14:32:04 -04:00
parent 4f19993889
commit 50089e0435
3 changed files with 57 additions and 0 deletions

View File

@@ -217,4 +217,56 @@ PNIDSchema.method('getServerMode', function getServerMode(): string {
return this.get('server_mode') || 'prod';
});
PNIDSchema.method('scrub', function scrub() {
// * Remove all personal info from a PNID
// * Username and PID remain so thye do not get assigned again
this.creation_date = '';
this.password = '';
this.birthdate = '';
this.gender = '';
this.country = '';
this.language = '';
this.email = {
address: '',
primary: false,
parent: false,
reachable: false,
validated: false,
validated_date: '',
id: 0
};
this.region = 0;
this.timezone = {
name: '',
offset: 0
};
this.mii = {
name: 'Default',
primary: false,
data: 'AwAAQOlVognnx0GC2/uogAOzuI0n2QAAAEBEAGUAZgBhAHUAbAB0AAAAAAAAAEBAAAAhAQJoRBgmNEYUgRIXaA0AACkAUkhQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGm9',
id: 0,
hash: '',
image_url: '',
image_id: 0
};
this.flags = {
active: false,
marketing: false,
off_device: false
};
this.connections = {
discord: {
id: ''
},
stripe: {
customer_id: '',
subscription_id: '',
price_id: '',
tier_level: 0,
tier_name: '',
latest_webhook_timestamp: 0
}
};
});
export const PNID: PNIDModel = model<IPNID, PNIDModel>('PNID', PNIDSchema);

View File

@@ -523,6 +523,10 @@ router.put('/@me/deletion', async (request: express.Request, response: express.R
}).end());
}
pnid.scrub();
await pnid.save();
response.send('');
});

View File

@@ -79,6 +79,7 @@ export interface IPNIDMethods {
updateMii(mii: { name: string, primary: string, data: string}): Promise<void>;
generateMiiImages(): Promise<void>;
getServerMode(): string;
scrub(): void;
}
interface IPNIDQueryHelpers {}