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
225 stars 821 forks source link

API - Select organization on registration #1703

Closed palisadoes closed 7 months ago

palisadoes commented 10 months ago

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

We are working on migrating the approval of requests to join organizations to a new Admin screen as outlined in this issue:

Prior to this the process was:

  1. New registrants joined the Community
  2. Super Admins would approve the request
  3. Approved registrants would login and select an organization

There were disadvantages to this approach:

  1. This gave too much responsibility to the Super Admin who may not necessarily know people requesting to join in the way an Admin would.
  2. The two step process where the organization was selected post approval, could have been reduced to a simpler single step.

Describe the solution you'd like

TALAWA API

TALAWA MOBILE

TALAWA ADMIN

OTHER

  1. You will need to write tests for the updated code
  2. All other functionality must be maintained

Describe alternatives you've considered

Approach to be followed (optional)

Additional context

  1. Related issues:
    1. https://github.com/PalisadoesFoundation/talawa-api/issues/1703
    2. https://github.com/PalisadoesFoundation/talawa/issues/2330
    3. https://github.com/PalisadoesFoundation/talawa-admin/issues/1440
  2. User definitions in the DB schema image

Potential internship candidates Please read this if you are planning to apply for a Palisadoes Foundation internship

Manik2708 commented 10 months ago

Hey @palisadoes can you assign this issue to me?

NayOoLwin5 commented 10 months ago

I would like to work on it.

lakshz commented 10 months ago

I'd like work on this

AVtheking commented 10 months ago

i would like to work on this sir please assign me this issue

Manik2708 commented 10 months ago

Hey, I am facing a problem, when an user is created an organization is asked from the user itslef Screenshot from 2024-01-18 00-15-16 And when membership request is made, a check is made that too with the admin of organization not superadmin Screenshot from 2024-01-18 00-17-23 So which registration is being talked about here? Can I get little more context?

palisadoes commented 10 months ago

This is related to a brand new user registering via the API selecting the organization that they want to be a member of.

BTW organizationUserBelongsto was deprecated yesterday

palisadoes commented 10 months ago
  1. As explained in the initial comment. Super Admins used to do the approvals, we now want this to be done by Admins.
  2. When a user is already in the system, they should be able to select organizations to join

Is there other clarification you require?

Manik2708 commented 10 months ago

So most of the logic has been made by me, please see the steps: (Only an overview) 1) As said in above comment organizationUserBelongsto is deprecated but not completely removed yet. That check will be removed completely in this issue. 2) The mutation SignUp will take Organization as a parameter, if it is null, default organization will be added in that user schema. 3) A membership request will be sent to the organization in this mutation. 4) createMember mutation will get rid of superAdmin 5) The isAdminAprooved will be made true in SignUp mutation. 6) The default organization will always be present no matter how many more organizations are joined by user.

My Questions: 1) The problem which I am facing is creating that default organization, should I add more commands to generate this default organization or just add this in the sample database? 2) Should I try for getting rid of isAdminAprooved variable as it will always be true?

palisadoes commented 10 months ago
  1. The default organization will need to be created automatically
    1. with setup if the DB is empty.
    2. as part of the sample database importation
  2. What does the isAdminApproved logic do?
  3. Yes cleanup organizationUserBelongsto
Manik2708 commented 10 months ago

Clear! gonna check Talawa Admin for handling this logic. Will raise the PR as soon as possible! Thanks for your cooperation!

palisadoes commented 10 months ago

You still haven't explained what the isAdminApproved logic does

Manik2708 commented 10 months ago

You still haven't explained what the isAdminApproved logic does

The unauthorised error is being sent by Talawa Admin when isAdminAprooved is false. Now there are two cases: 1) User tries to enter the Admin site without any Organization. 2) User already know his Organization. For the first case, the registration mutation has to make this bool variable true, so that User can enter the Admin pannel and then select organization. In the second case a membership request has to be made, then only this variable will become true. Initially I thought to make this variable as true in the SignUp mutation but then the need wouldn't be followed as then all users would enter the Admin Panel to select organizations but this is very unsecured and unnecessary. So in the end my approach will be: If organization provided by user is null then isAdminAprooved has to become true in the registration mutation itself. Else a membership request will be sent to the organization with isAdminAprooved as false.

palisadoes commented 10 months ago
  1. Why can't the user select the organization as part of a dropdown in the registration process so that they never have to get access to an Admin screen? The request would go straight to the Admin.
  2. If the the registration is approved, the user would go straight to their selected organization user portal screens

It seems like unnecessary logic.

Manik2708 commented 10 months ago
  1. Why can't the user select the organization as part of a dropdown in the registration process so that they never have to get access to an Admin screen? The request would go straight to the Admin.
  2. If the the registration is approved, the user would go straight to their selected organization user portal screens

It seems like unnecessary logic.

So you are saying, Choosing Organization will be necessary. If user chooses the Default Organization, then membership request will be made to that default organization. Thanks for this clarification!

palisadoes commented 10 months ago

Yes, we should be able to deprecate the field if we make selecting an organization on registration mandatory

Manik2708 commented 10 months ago

I want to ask whether acceptAdmin mutation should be removed or not, because I think that it's only use is to accept the request of newly created member by superAdmin, Please let me know if I am wrong! Thanks

palisadoes commented 10 months ago
  1. There is a userRegistrationRequired flag in the schema that is used to determine whether newly registered users need to be approved by an Admin to join the organization. It should really be named userRegistrationApprovalRequired image
  2. Is it related to that?
Manik2708 commented 10 months ago

No, I am talking about this adminAprooved in Talawa Admin IMG_20240121_125626 This is the mutation in Talawa API making it true IMG_20240121_125739

palisadoes commented 10 months ago

The logic is used throughout the Admin code but seems to be only set to false for testing purposes. Is that what you mean?

  1. Looking at the schema, I think it's a hack to make sure the user is always admin approved until the feature was truly fixed.
  2. It should really be part of an approval per organization.

This will need to be fixed as part of this issue. We need:

  1. New user registrations to be approved by the Admin (or automatically approved) depending on the userRegistrationRequired flag.
  2. Approvals on a per organization basis and reflected in the User schema.
    1. The Admin and Mobile repos will need to be adjusted accordingly.
  3. Users to only have the choice to easily switch between organizations for which they have been pre-approved, or else they will need to register with the new organization that they want to join.
Manik2708 commented 10 months ago

So I have prepared two workflows, the only difference between those workflows is when user tries to SignUp with the organization which has userRegistrationRequired=false: 1) A membership request will be made and no matter whether the above flag is true or false, Admins of the organization has to review the request.

WhatsApp Image 2024-01-21 at 17 54 06(2) 2) Or for only those users who have chosen that organization which have the above flag as false, request can be sent to superAdmins

WhatsApp Image 2024-01-21 at 17 54 06 If the requirement is to automatic approve the request sent to these organizations, then that can be also implemented but that will not be secured as any spam user could enter with that organization. I can think of more ways also, if you don't like the above workflows!

palisadoes commented 10 months ago

The super admin is not required. If an admin says that they don't need to approve registrations / signups then the user should just log straight in.

Most cloud services are like this, there is an email verification step on signup, then you login. There is no human interaction. The registration approval required step is to involve a human, namely the Admin and in the Organization level screens.

The super admin role is primarily for the oversight of organizations. They should see organization specific alerts when they click through to the organizations from the Admin orglist screen.

Manik2708 commented 10 months ago

Ok, so will work on this. Thanks!

Shubh152 commented 10 months ago

@Manik2708 ,Wanted to know will the membershipRequests key in the Organization model be populated in your solution so that it can be accessed from the admin repo as it wasn't previously? Thanks.

Manik2708 commented 10 months ago

@Manik2708 ,Wanted to know will the membershipRequests key in the User model be populated in your solution so that it can be accessed from the admin repo as it wasn't previously? Thanks.

Please can you provide a little more description?

Shubh152 commented 10 months ago

Is the membershipRequest array in the Organization model definition populated with the requested organization in your solution? It was not getting populated until now. I need to know this so that I can access it in the request section for an organization in the Admin repo. @Manik2708

Manik2708 commented 10 months ago

Is the membershipRequest array in the Organization model definition populated with the requested organization in your solution? It was not getting populated until now. I need to know this so that I can access it in the request section for an organization in the Admin repo. @Manik2708

I haven't changed any mutation other than signUp and acceptMembershipRequest. In first mutation User is sent while in other MembershipRequest is sent.

palisadoes commented 9 months ago

@Manik2708

This had to be reverted. It was causing these issues

Please resubmit your PR

Manik2708 commented 9 months ago

@Manik2708

This had to be reverted. It was causing these issues

Please resubmit your PR

Ok, will fix it!

github-actions[bot] commented 9 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.

Manik2708 commented 9 months ago

Working

github-actions[bot] commented 9 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.

Olatade commented 9 months ago

@Manik2708 are you still working on this ?

Manik2708 commented 9 months ago

Yes, the PR is under review.

github-actions[bot] commented 8 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.

github-actions[bot] commented 8 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 8 months ago
AVtheking commented 8 months ago

I would like to work on it .

palisadoes commented 8 months ago

@AVtheking You should also work on this issue as it's related. Please ask to be assigned.

AVtheking commented 8 months ago

Ok sir.