capgo icon indicating copy to clipboard operation
capgo copied to clipboard

Cannot delete user from auth table

Open riderx opened this issue 11 months ago • 2 comments

Describe the bug/issue When try to delete user from auth table it fail where it should work

riderx avatar Feb 04 '25 04:02 riderx

fix that and add test for it @devin

riderx avatar Mar 15 '25 17:03 riderx

I've created a PR to fix this issue: #1082

Problem Analysis

The issue was that users couldn't be deleted from the auth table due to incomplete implementation of the deletion process. Specifically:

  1. The on_user_delete.ts trigger wasn't properly handling DELETE operations - it was looking for body.record instead of body.old_record for deleted user data
  2. The trigger wasn't hashing emails before inserting into the deleted_account table
  3. The implementation wasn't aligned with the new queue-based approach for user deletion

Solution Implemented

The PR implements the following fixes:

  1. Updated the on_user_delete.ts trigger to properly handle DELETE operations by using body.old_record
  2. Added email hashing functionality in the trigger before inserting into deleted_account table
  3. Created a new migration file to document the update to the on_user_delete trigger
  4. Aligned the implementation with the new queue-based approach for user deletion

The changes ensure that when a user is deleted, their email is properly hashed and stored in the deleted_account table, and all related cleanup operations are performed correctly.