BE - Allow User to Make Their Profile Public or Private #63
Labels
ansopedia
backend
database
enhancement
New feature or request
good first issue
Good for newcomers
hacktoberfest
Milestone
Description:
We need to implement functionality that allows users to toggle their profile visibility between public and private. By default, profiles are public, but users should have the option to make their profile private if they choose.
Key Requirements:
Toggle Profile Visibility API:
PATCH /profile/visibility
route to allow users to update the visibility of their profile (public or private).validateAccessToken
middleware to authenticate the requesting user.Profile Schema Update:
isPublic
in the profile schema to store the visibility status of the user's profile.true
(public).Profile Visibility Logic:
isPublic: true
): When a profile is public, anyone can view the restricted fields as mentioned in the "View Another User's Profile" issue.isPublic: false
): If a profile is private, it will not be viewable by others except for a message like:"This profile is private."
Profile Controller and Service:
toggleProfileVisibility
method inProfileController
to handle toggling the profile'sisPublic
status.ProfileService
to update the profile's visibility based on the authenticated user making the request.Zod Validation:
isPublic
field is allowed to be updated in this API call.Test Cases:
Write unit tests for the following scenarios:
isPublic
) are rejected by the validation schema.Tasks:
toggleProfileVisibility
method inProfileController
to update theisPublic
flag.PATCH /profile/visibility
route inprofile.route.ts
.isPublic
field inprofile.validation.ts
.validateAccessToken
middleware is used to authenticate the user.isPublic
.The text was updated successfully, but these errors were encountered: