Repository navigation
feat: allow profile owners to disable and re-enable their account - #43
Open
fordimalanda wants to merge 1 commit into
Open
fordimalanda wants to merge 1 commit into
fordimalanda wants to merge 1 commit into
Conversation
Closes congodevelopersclub#42 Profile owners can now disable their account so it no longer shows up in listings or searches, and enable it again whenever they want. - add a DISABLED value to ProfileAccountStatus, plus a migration that extends the enum column and adds `account_status_before_disabled` - add PUT /api/v1/profiles/{profile}/disable and PUT /api/v1/profiles/{profile}/enable (authenticated, owner only) - remember the previous status when disabling, so enabling restores it (a VALIDATED profile comes back VALIDATED instead of going through moderation again) - hide disabled profiles from GET /profiles and GET /profiles/search through a `visible()` scope on the Profile model - return 404 on GET /profiles/{profile} for a disabled profile, except for its owner - prevent the admin validation endpoint from setting DISABLED, since this status belongs to the owner - add feature tests covering the new flow
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does
Closes #42
Profile owners can now disable their account. A disabled profile stops showing up anywhere public, and comes back as soon as its owner enables it again.
Changes
New status
DISABLEDtoProfileAccountStatus.DISABLEDto theaccount_statusenum column and adds a nullableaccount_status_before_disabledcolumn.New endpoints (authenticated, owner only)
PUT/api/v1/profiles/{profile}/disableDISABLEDand remembers its current statusPUT/api/v1/profiles/{profile}/enable403, and a guest gets a401.Why remember the previous status?
If we simply moved a profile back to
PENDING_VALIDATIONwhen it is enabled again, an already validated member would have to go through moderation again just because they hid their profile for a while. Saving the previous status avoids that. This column is hidden from API responses.Filtering
visible()scope onProfilethat excludes disabled profiles.GET /profilesandGET /profiles/search.GET /profiles/{profile}returns404for a disabled profile, except when the caller is its owner. This lets the owner still see their own profile and enable it again.Guard on the validation endpoint
PUT /profiles/{profile}/validateno longer acceptsDISABLED. That status belongs to the owner and should not be set through moderation.Other
ProfileFactory::disabled()state for tests.Tests
403/401cases, idempotency, restoring the previous status, hiding from list, search and show, the owner can still see their profile, and validate rejectsDISABLED.How to try it