ryer.io

Debugging iOS Signup Flow: Handling Soft Deleted Users

TL;DR

  • Soft-deleted users lead to a 500 error on re-registration.
  • Lack of error handling results in incorrect navigation.
  • Problem lies in backend handling of deleted users.
  • Solution involves fixing backend check for existing users.

Today, I tackled an issue during the re-registration of a user on iOS, focusing on handling the soft deletion of user data within our app’s database. This exploration led me through a maze of error messages, logical fixes, and state management. Here’s a streamlined version of my debugging process.

Initial Problem Diagnosis

  1. Re-registration Attempt: I attempted to re-register using my gus@ryer.io email. The app cycled back to the onboarding screen, spitting out a 500 error, an unhandled server issue.
  2. Investigating the Error: The backend failed to handle cases where the user was soft-deleted. The app was attempting to create a new user, resulting in a duplicate key error from the database.

Tracing the Error Source

  • Error Manifestation: Upon signup, the Auth0 prompt transitioned the app background when the signup failed. This led to a sign-out without adequate user feedback.
  • Backend Investigation: The issue lay at the register endpoint where the app did not check if a user was previously marked as deleted.
  • Frontend Logging: Checked the Auth context and discovered signing up resulted in proper state changes but failed navigation due to unhandled backend logic.

Implementing the Fix

  1. Backend Logic Update: I modified the backend to accurately set the isExistingUser field based on soft-deletion states, preventing attempts to recreate pre-existing users.
  2. Error Handling: Introduced better error handling to inform users how to proceed after a soft-delete - like suggesting a normal sign-in instead.
  3. Frontend State Management: Cleaned up state transition logic to ensure device storage and initialization reflected correctly when navigating the app.

Results and Further Testing

  • Positive Outcome: After implementing the updates, testing showed a 200 response at the register endpoint, affirming the corrected user check flow in the backend.
  • Remaining Challenges: Despite successful registration, navigation required further debug to ensure seamless user transition post-registration.

This exploration wasn’t just about fixing bugs but enhancing system robustness, ensuring scenarios like soft-deletion don’t trip up user experiences. It remains crucial to maintain consistent checks and improve feedback mechanisms for end users navigating such edge cases.