PalisadoesFoundation / talawa-api

API Backend for the Talawa Mobile App. Click on the link below to see our documentation
https://docs.talawa.io/
GNU General Public License v3.0
215 stars 749 forks source link

[userTypeFix] API: Remove legacy references to `userType` #2108

Open palisadoes opened 6 months ago

palisadoes commented 6 months ago

Is your feature request related to a problem? Please describe.

We recently updated the code base to replace the authorization mechanism for users from being a userType field in the database’s User collection to an appUserProfile field.

Describe the solution you'd like

  1. Though the updated code works, there are still many unused references to userType in the code base.
  2. Some of these references may still be accessible under certain circumstances creating malfunctioning code. These sections will need to be refactored.

The aim is for the userType to be removed, while maintaining the expected functionality of the app

Describe alternatives you've considered

Approach to be followed (optional)

Additional context

  1. This is the project tracking the userType adjustment
    1. https://github.com/orgs/PalisadoesFoundation/projects/24/views/1
  2. All tests must be valid and pass. There must be no reduction in test code coverage
  3. All functionality must be maintained
  4. These are the files that need to be updated in this repo
schema.graphql
src/checks.ts
src/directives/directiveTransformer/roleDirectiveTransformer.ts
src/models/User.ts
src/resolvers/Mutation/deleteAdvertisement.ts
src/resolvers/Mutation/login.ts
src/resolvers/Mutation/signUp.ts
src/server.ts
src/typeDefs/directives.ts
src/typeDefs/enums.ts
src/typeDefs/inputs.ts
src/typeDefs/mutations.ts
src/types/generatedGraphQLTypes.ts
src/utilities/createSampleOrganizationUtil.ts
tests/directives/directiveTransformer/authDirectiveTransformer.spec.ts
tests/directives/directiveTransformer/roleDirectiveTransformer.spec.ts
tests/helpers/actionItemCategory.ts
tests/helpers/actionItem.ts
tests/helpers/agendaCategory.ts
tests/helpers/agendaItem.ts
tests/helpers/agendaSection.ts
tests/helpers/checkIn.ts
tests/helpers/directChat.ts
tests/helpers/donation.ts
tests/helpers/events.ts
tests/helpers/eventsWithRegistrants.ts
tests/helpers/feedback.ts
tests/helpers/FundraisingCampaignPledge.ts
tests/helpers/Fund.ts
tests/helpers/groupChat.ts
tests/helpers/group.ts
tests/helpers/membershipRequests.ts
tests/helpers/plugins.ts
tests/helpers/posts.ts
tests/helpers/tags.ts
tests/helpers/userAndOrg.ts
tests/helpers/userAndUserFamily.ts
tests/helpers/user.ts
tests/resolvers/ActionItem/assignee.spec.ts
tests/resolvers/ActionItem/assigner.spec.ts
tests/resolvers/ActionItemCategory/creator.spec.ts
tests/resolvers/ActionItem/creator.spec.ts
tests/resolvers/ActionItem/event.spec.ts
tests/resolvers/AgendaCategory/createdBy.spec.ts
tests/resolvers/AgendaCategory/organization.spec.ts
tests/resolvers/AgendaCategory/updatedBy.spec.ts
tests/resolvers/AgendaItem/categories.spec.ts
tests/resolvers/AgendaItem/createdby.spec.ts
tests/resolvers/AgendaItem/organization.spec.ts
tests/resolvers/AgendaItem/relatedEvent.spec.ts
tests/resolvers/AgendaItem/updatedBy.spec.ts
tests/resolvers/AgendaSection/createdBy.spec.ts
tests/resolvers/AgendaSection/items.spec.ts
tests/resolvers/AgendaSection/relatedEvent.spec.ts
tests/resolvers/CheckIn/user.spec.ts
tests/resolvers/Comment/creator.spec.ts
tests/resolvers/Event/attendees.spec.ts
tests/resolvers/Event/creator.spec.ts
tests/resolvers/Event/recurrenceRule.spec.ts
tests/resolvers/EventVolunteer/creator.spec.ts
tests/resolvers/EventVolunteer/user.spec.ts
tests/resolvers/Fund/creator.spec.ts
tests/resolvers/middleware/currentUserExists.spec.ts
tests/resolvers/Mutation/acceptAdmin.spec.ts
tests/resolvers/Mutation/acceptMembershipRequest.spec.ts
tests/resolvers/Mutation/addEventAttendee.spec.ts
tests/resolvers/Mutation/addFeedback.spec.ts
tests/resolvers/Mutation/addOrganizationCustomField.spec.ts
tests/resolvers/Mutation/addOrganizationImage.spec.ts
tests/resolvers/Mutation/addPledgeToFundraisingCampaign.spec.ts
tests/resolvers/Mutation/addUserCustomData.spec.ts
tests/resolvers/Mutation/addUserImage.spec.ts
tests/resolvers/Mutation/addUserToGroupChat.spec.ts
tests/resolvers/Mutation/addUserToUserFamily.spec.ts
tests/resolvers/Mutation/adminRemoveEvent.spec.ts
tests/resolvers/Mutation/adminRemoveGroup.spec.ts
tests/resolvers/Mutation/assignUserTag.spec.ts
tests/resolvers/Mutation/blockPluginCreationBySuperadmin.spec.ts
tests/resolvers/Mutation/blockUser.spec.ts
tests/resolvers/Mutation/cancelMembershipRequest.spec.ts
tests/resolvers/Mutation/checkIn.spec.ts
tests/resolvers/Mutation/createActionItemCategory.spec.ts
tests/resolvers/Mutation/createActionItem.spec.ts
tests/resolvers/Mutation/createAdmin.spec.ts
tests/resolvers/Mutation/createAdvertisement.spec.ts
tests/resolvers/Mutation/createAgendaCategory.spec.ts
tests/resolvers/Mutation/createAgendaItem.spec.ts
tests/resolvers/Mutation/createAgendaSection.spec.ts
tests/resolvers/Mutation/createComment.spec.ts
tests/resolvers/Mutation/createDirectChat.spec.ts
tests/resolvers/Mutation/createDonation.spec.ts
tests/resolvers/Mutation/createEvent.spec.ts
tests/resolvers/Mutation/createEventVolunteer.spec.ts
tests/resolvers/Mutation/createFundCampaignPledge.spec.ts
tests/resolvers/Mutation/createFundraisingCampaign.spec.ts
tests/resolvers/Mutation/createFund.spec.ts
tests/resolvers/Mutation/createGroupChat.spec.ts
tests/resolvers/Mutation/createMember.spec.ts
tests/resolvers/Mutation/createMessageChat.spec.ts
tests/resolvers/Mutation/createOrganization.spec.ts
tests/resolvers/Mutation/createPost.spec.ts
tests/resolvers/Mutation/createUserFamily.spec.ts
tests/resolvers/Mutation/createUserTag.spec.ts
tests/resolvers/Mutation/createVenue.spec.ts
tests/resolvers/Mutation/deleteAdvertisement.spec.ts
tests/resolvers/Mutation/deleteAgendaCategory.spec.ts
tests/resolvers/Mutation/deleteVenue.spec.ts
tests/resolvers/Mutation/editVenue.spec.ts
tests/resolvers/Mutation/forgotPassword.spec.ts
tests/resolvers/Mutation/inviteEventAttendee.spec.ts
tests/resolvers/Mutation/joinPublicOrganization.spec.ts
tests/resolvers/Mutation/leaveOrganization.spec.ts
tests/resolvers/Mutation/likeComment.spec.ts
tests/resolvers/Mutation/likePost.spec.ts
tests/resolvers/Mutation/login.spec.ts
tests/resolvers/Mutation/logout.spec.ts
tests/resolvers/Mutation/otp.spec.ts
tests/resolvers/Mutation/refreshToken.spec.ts
tests/resolvers/Mutation/registerEventAttendee.spec.ts
tests/resolvers/Mutation/registerForEvent.spec.ts
tests/resolvers/Mutation/rejectAdmin.spec.ts
tests/resolvers/Mutation/rejectMembershipRequest.spec.ts
tests/resolvers/Mutation/removeActionItem.spec.ts
tests/resolvers/Mutation/removeAdmin.spec.ts
tests/resolvers/Mutation/removeAgendaItem.spec.ts
tests/resolvers/Mutation/removeAgendaSection.spec.ts
tests/resolvers/Mutation/removeComment.spec.ts
tests/resolvers/Mutation/removeDirectChat.spec.ts
tests/resolvers/Mutation/removeEventAttendee.spec.ts
tests/resolvers/Mutation/removeEvent.spec.ts
tests/resolvers/Mutation/removeEventVolunteer.spec.ts
tests/resolvers/Mutation/removeFundCampaignPledge.spec.ts
tests/resolvers/Mutation/removeFundraisingCampaign.spec.ts
tests/resolvers/Mutation/removeFund.spec.ts
tests/resolvers/Mutation/removeGroupChat.spec.ts
tests/resolvers/Mutation/removeMember.spec.ts
tests/resolvers/Mutation/removeOrganizationCustomField.spec.ts
tests/resolvers/Mutation/removeOrganizationImage.spec.ts
tests/resolvers/Mutation/removeOrganization.spec.ts
tests/resolvers/Mutation/removePost.spec.ts
tests/resolvers/Mutation/removeUserCustomData.spec.ts
tests/resolvers/Mutation/removeUserFamily.spec.ts
tests/resolvers/Mutation/removeUserFromGroupChat.spec.ts
tests/resolvers/Mutation/removeUserFromUserFamily.spec.ts
tests/resolvers/Mutation/removeUserImage.spec.ts
tests/resolvers/Mutation/removeUserTag.spec.ts
tests/resolvers/Mutation/resetCommunity.spec.ts
tests/resolvers/Mutation/revokeRefreshTokenForUser.spec.ts
tests/resolvers/Mutation/saveFcmToken.spec.ts
tests/resolvers/Mutation/sendMembershipRequest.spec.ts
tests/resolvers/Mutation/sendMessageToDirectChat.spec.ts
tests/resolvers/Mutation/sendMessageToGroupChat.spec.ts
tests/resolvers/Mutation/signUp.spec.ts
tests/resolvers/Mutation/togglePostPin.spec.ts
tests/resolvers/Mutation/unassignUserTag.spec.ts
tests/resolvers/Mutation/unblockUser.spec.ts
tests/resolvers/Mutation/unlikeComment.spec.ts
tests/resolvers/Mutation/unlikePost.spec.ts
tests/resolvers/Mutation/unregisterForEventByUser.spec.ts
tests/resolvers/Mutation/updateActionItemCategory.spec.ts
tests/resolvers/Mutation/updateActionItem.spec.ts
tests/resolvers/Mutation/updateAdvertisement.spec.ts
tests/resolvers/Mutation/updateAgendaCategory.spec.ts
tests/resolvers/Mutation/updateAgendaItem.spec.ts
tests/resolvers/Mutation/updateAgendaSection.spec.ts
tests/resolvers/Mutation/updateCommunity.spec.ts
tests/resolvers/Mutation/updateEvent.spec.ts
tests/resolvers/Mutation/updateFundCampaignPledge.spec.ts
tests/resolvers/Mutation/updateFundraisingCampaign.spec.ts
tests/resolvers/Mutation/updateFund.spec.ts
tests/resolvers/Mutation/updateLanguage.spec.ts
tests/resolvers/Mutation/updateOrganization.spec.ts
tests/resolvers/Mutation/updatePost.spec.ts
tests/resolvers/Mutation/updateUserPassword.spec.ts
tests/resolvers/Mutation/updateUserRoleInOrganization.spec.ts
tests/resolvers/Mutation/updateUserTag.spec.ts
tests/resolvers/Organization/advertisements.spec.ts
tests/resolvers/Organization/agendaCategories.spec.ts
tests/resolvers/Organization/creator.spec.ts
tests/resolvers/Organization/image.spec.ts
tests/resolvers/Organization/membershipRequests.spec.ts
tests/resolvers/Organization/posts.spec.ts
tests/resolvers/Post/comments.spec.ts
tests/resolvers/Post/creator.spec.ts
tests/resolvers/Query/advertisementsConnection.spec.ts
tests/resolvers/Query/agendaCategory.spec.ts
tests/resolvers/Query/agendaItemById.spec.ts
tests/resolvers/Query/customDataByOrganization.spec.ts
tests/resolvers/Query/customFieldsByOrganization.spec.ts
tests/resolvers/Query/directChatsByUserID.spec.ts
tests/resolvers/Query/eventsByOrganizationConnection.spec.ts
tests/resolvers/Query/eventsByOrganization.spec.ts
tests/resolvers/Query/event.spec.ts
tests/resolvers/Query/getAgendaSection.spec.ts
tests/resolvers/Query/getAllAgendaItems.spec.ts
tests/resolvers/Query/getEventAttendeesByEventId.spec.ts
tests/resolvers/Query/getEventAttendee.spec.ts
tests/resolvers/Query/hasSubmittedFeedback.spec.ts
tests/resolvers/Query/me.spec.ts
tests/resolvers/Query/organizationsConnection.spec.ts
tests/resolvers/Query/organizations.spec.ts
tests/resolvers/Query/registeredEventsByUser.spec.ts
tests/resolvers/Query/usersConnection.spec.ts
tests/resolvers/Query/user.spec.ts
tests/resolvers/Query/users.spec.ts
tests/resolvers/Subscription/messageSentToDirectChat.spec.ts
tests/resolvers/UserFamily/creator.spec.ts
tests/resolvers/User/post.spec.ts
tests/resolvers/UserTag/usersAssignedTo.spec.ts
tests/utilities/adminCheck.spec.ts
tests/utilities/auth.spec.ts
tests/utilities/createSampleOrganizationUtil.spec.ts
tests/utilities/superAdminCheck.spec.ts
tests/utilities/uploadImage.spec.ts
tests/utilities/userFamilyAdminCheck.spec.ts

Potential internship candidates

NamitBhutani commented 6 months ago

I'd like to work on this issue!

NamitBhutani commented 6 months ago

Due to sudden academic commitments, I wouldn't be able to fix the issue in time, hence I have unassigned myself.

Manik2708 commented 6 months ago

Can I work on this issue?

Manik2708 commented 6 months ago

@palisadoes I think there is some confusion. There are no references to userType in mutations and their tests. I think you searched userType and TestUserType was also included in this. Here userType is altogether different from TestUserType. Please see the images below. Please verify once again from the files.

Screenshot from 2024-04-15 01-43-54

Screenshot from 2024-04-15 01-44-25

palisadoes commented 6 months ago

Should it be renamed for clarity or do you feel it should remain, and why?

Manik2708 commented 6 months ago

Should it be renamed for clarity or do you feel it should remain, and why?

I don't think there is any need of renaming. userType and TestUerType are able to express their difference by their name. Also it will lead to unnecessary refactoring. Rest I leave to you!

palisadoes commented 6 months ago

Thanks. Closing

Manik2708 commented 6 months ago

Thanks. Closing

I think there is some mis-interpretation. There are some references of userType in just 5-6 files. They needed to be removed. I request to reopen the issue.

varshith257 commented 6 months ago

@palisadoes There are still some files of this userType Reference. I think we have to remove them, they causing block to progress of my PR too. Though I fixed it , Manik will make a PR as he assigned for this issue.

We have to reopen this issue

Manik2708 commented 6 months ago

Sorry for being inactive. @palisadoes, there is a problem. There are some mutations on which a userRole directive is imposed. There are some mutations which can only be used by a specific user. Like createAdmin can only be used by SUPERADMIN. Now, as userType is removed, I can't found logic of finding the type of user in userRole directive. I am thinking of creating of two directives: one for Admin and other for Superadmin. I need to consult to that mentor who have worked on directives. Please help!!

palisadoes commented 5 months ago

Please ask the contributors on the #talawa-projects slack channel. Many of them worked on the userType migration

github-actions[bot] commented 5 months ago

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

dhanagopu commented 5 months ago

@Manik2708 Are you still working on this?

github-actions[bot] commented 5 months ago

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.

palisadoes commented 5 months ago

Unassigning. Inactivity

github-actions[bot] commented 4 months ago

This issue did not get any activity in the past 10 days and will be closed in 180 days if no update occurs. Please check if the develop branch has fixed it and report again or close the issue.