feat(profile): implement user-initiated GDPR-compliant profile deletion
- Add DELETE /users/me endpoint with cascading data removal - Implement frontend confirmation dialog and deletion flow - Add audit logging for deletion requests - Update localization files for new UI strings - Add scheduled cleanup service for AI traces - Document GDPR compliance in technical specification BREAKING CHANGE: Users can now permanently delete their profiles and associated data
This commit is contained in:
@@ -84,7 +84,21 @@ export class UsersService {
|
||||
return { temporaryPassword };
|
||||
}
|
||||
|
||||
updateEmail(id: number, email: string) {
|
||||
return this.prisma.user.update({ where: { id }, data: { email } });
|
||||
async deleteUserAndData(userId: number) {
|
||||
await this.prisma.$transaction([
|
||||
this.prisma.product.deleteMany({ where: { ownerId: userId } }),
|
||||
this.prisma.recipe.deleteMany({ where: { ownerId: userId } }),
|
||||
this.prisma.inventoryItem.deleteMany({ where: { userId } }),
|
||||
this.prisma.mealPlanEntry.deleteMany({ where: { userId } }),
|
||||
this.prisma.user.delete({ where: { id: userId } }),
|
||||
]);
|
||||
await this.prisma.auditLog.create({
|
||||
data: {
|
||||
action: 'USER_DELETION',
|
||||
userId,
|
||||
metadata: { message: 'User initiated deletion of their profile and data.' },
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user