Skip to content

Feat: soft delete account with 30 days grace period#653

Open
patilmanasvi wants to merge 13 commits into
Shivayan09:mainfrom
patilmanasvi:feat/soft-delete-account
Open

Feat: soft delete account with 30 days grace period#653
patilmanasvi wants to merge 13 commits into
Shivayan09:mainfrom
patilmanasvi:feat/soft-delete-account

Conversation

@patilmanasvi
Copy link
Copy Markdown
Contributor

@patilmanasvi patilmanasvi commented May 27, 2026

Related Issue

Closes #607

Overview

This PR adds an Instagram-style account deletion system where accounts are first deactivated for 30 days before being permanently deleted.

Users can restore their account anytime during the grace period simply by logging back in.

Type of Change

  • UI enhancement
  • Feature improvement
  • Bug fix
  • Documentation update

Changes Made

Backend

  • Added isDeactivated and deletionScheduledAt to User model
  • Added:
    • scheduleAccountDeletion
    • cancelAccountDeletion
  • Auto-reactivate account on login
  • Hide deactivated accounts from search/profile lookups
  • Added daily cron job for permanent deletion after 30 days

Frontend

  • Added DeactivateAccountModal
  • Added Danger Zone section in Profile Settings
  • Added type-to-confirm (DELETE) safety input
  • Added reactivation success toast on login

Testing

  • Deactivate account from Settings → Danger Zone
  • Verify logout after deletion request
  • Login again to restore account
  • Confirm deactivated accounts are hidden from search/profile
  • Test cron job by setting deletionScheduledAt to a past date

Checklist

  • Code runs successfully
  • Changes tested locally
  • No console errors
  • Follows existing project structure
  • DCO sign-off
Screenshot 2026-05-28 at 2 57 44 AM
Screen.Recording.2026-05-28.at.2.52.49.AM.mov
Screenshot 2026-05-28 at 2 52 33 AM

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 27, 2026

@patilmanasvi is attempting to deploy a commit to the Shivayan's projects Team on Vercel.

A member of the Team first needs to authorize it.

@patilmanasvi patilmanasvi marked this pull request as ready for review May 27, 2026 21:31
@patilmanasvi
Copy link
Copy Markdown
Contributor Author

@Shivayan09 kindly check

Copy link
Copy Markdown
Owner

@Shivayan09 Shivayan09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The server crashes in localhost, so there are errors in server
  • You replaced the noraml "Logged in successfully" text with "Welcome back, account not deleted" which then shows then 2nd text even on normal login
  • You pushed the changes of "save as draft" issue here as well, which mixes 2 prs. So please revert the changes of that issue
  • Account deletion is fine, but it leaves behind orphaned account related data like likes, comments and more, so clean those up as well

@patilmanasvi
Copy link
Copy Markdown
Contributor Author

Will submit changes by eod

@patilmanasvi patilmanasvi force-pushed the feat/soft-delete-account branch from be4f12b to 869dc79 Compare May 28, 2026 16:30
…tend only

Signed-off-by: patilmanasvi <manasvipatil2286@gmail.com>
…hard delete

Signed-off-by: patilmanasvi <manasvipatil2286@gmail.com>
Signed-off-by: patilmanasvi <manasvipatil2286@gmail.com>
@patilmanasvi
Copy link
Copy Markdown
Contributor Author

@Shivayan09 kindly check. the changes are done

@patilmanasvi patilmanasvi requested a review from Shivayan09 May 28, 2026 21:40
@Shivayan09
Copy link
Copy Markdown
Owner

@patilmanasvi Your branch has merge conflicts, kindly pull the recent-most code from main branch and resolve the conflicts (Don't remove/overwrite any existing functionality as well)

Copy link
Copy Markdown
Owner

@Shivayan09 Shivayan09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature is close, but a few fixes are still needed before this is safe to merge:

  • Enforce isDeactivated in authMiddleware so deactivated users cannot keep using protected endpoints.
  • Finish the hard-delete job: delete Comment docs, remove follows/bookmarks/likes tied to the user, and clean up schema-accurate relations only.
  • Add a server-side cutoff for reactivation so accounts can only be restored within the 30-day grace period, not indefinitely.
  • Add tests for deactivation, reactivation, and the scheduled deletion path.

A couple of changes look out of scope / unnecessary for this feature:

  • getUserProfile now selects followers and followRequests, but those fields aren’t part of the User schema.
  • If possible, keep the PR focused on account lifecycle changes only and avoid unrelated cleanup unless it’s required for the flow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Soft-delete account with 30-day grace period

2 participants