Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sign up route changed with bug fix and proper data importation #1770

Closed
wants to merge 65 commits into from

Conversation

Manik2708
Copy link
Contributor

What kind of change does this PR introduce?

  1. As per the need, now responsibility of creating a fresh member is shifted to Admin of organization from Super Admin.
  2. Fixes the issue that previously adminApproved was only for testing purpose but now will be used for authenticating whether user is actually Admin approved or not.
  3. acceptMemeberShip mutation is also modified to approve the user if it's his first request.
  4. @ts-ignore and delete operand was used before to delete the password from createdUser, now omit method is used by creating a separate interface of the user which doesn't consists password.
  5. Wrong import of data bug fixed

Issue Number:

Fixes #1703

Did you add tests for your changes?

Yes

Snapshots/Videos:

Video link for reference of bug getting fixed, and Talawa Admin working and importing of data in setup: https://www.mediafire.com/file/ujr35ynmlxy6ic3/Untitled+design.mp4/file

New SignUp Route

0

New Accept Membership Request Route

01

Query with output, when user tries to signUp with Organization that doesn't require User Registration

1

The organization which was used in above query

2

Query with output, when user tries to signUp with Organization that require User Registration

3

The default organization, which was also used in above query

4

Setup Route

5

If relevant, did you update the documentation?

Summary

Does this PR introduce a breaking change?

Yes, I have tried to make the system more secured by using `adminApproved` flag.

Other information

Have you read the contributing guide?

Yes

Copy link

github-actions bot commented Jan 31, 2024

Our Pull Request Approval Process

We have these basic policies to make the approval process smoother for our volunteer team.

Testing Your Code

Please make sure your code passes all tests. Our test code coverage system will fail if these conditions occur:

  1. The overall code coverage drops below the target threshold of the repository
  2. Any file in the pull request has code coverage levels below the repository threshold
  3. Merge conflicts

The process helps maintain the overall reliability of the code base and is a prerequisite for getting your PR approved. Assigned reviewers regularly review the PR queue and tend to focus on PRs that are passing.

Reviewers

Do not assign reviewers. Our Queue Monitors will review your PR and assign them.
When your PR has been assigned reviewers contact them to get your code reviewed and approved via:

  1. comments in this PR or
  2. our slack channel

Reviewing Your Code

Your reviewer(s) will have the following roles:

  1. arbitrators of future discussions with other contributors about the validity of your changes
  2. point of contact for evaluating the validity of your work
  3. person who verifies matching issues by others that should be closed.
  4. person who gives general guidance in fixing your tests

CONTRIBUTING.md

Read our CONTRIBUTING.md file. Most importantly:

  1. PRs with issues not assigned to you will be closed by the reviewer
  2. Fix the first comment in the PR so that each issue listed automatically closes

Other

  1. 🎯 Please be considerate of our volunteers' time. Contacting the person who assigned the reviewers is not advised unless they ask for your input. Do not @ the person who did the assignment otherwise.
  2. Read the CONTRIBUTING.md file make

@Manik2708
Copy link
Contributor Author

Manik2708 commented Jan 31, 2024

I have tested the api in all the way I can think of, @palisadoes, the infinite scrolling bug is fixed now and importation of data and bug being fixed is shown in video (link is in PR description, as video was large)

Copy link

codecov bot commented Jan 31, 2024

Codecov Report

Attention: Patch coverage is 86.34921% with 43 lines in your changes are missing coverage. Please review.

Project coverage is 96.06%. Comparing base (36b3f5d) to head (e2b6800).

Files Patch % Lines
src/setup/importDefaultOrganization.ts 27.08% 35 Missing ⚠️
src/resolvers/Mutation/signUp.ts 96.42% 5 Missing ⚠️
src/utilities/loadDefaultOrganizationScript.ts 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1770      +/-   ##
===========================================
- Coverage    96.17%   96.06%   -0.11%     
===========================================
  Files          333      336       +3     
  Lines        22536    22726     +190     
  Branches      1949     1995      +46     
===========================================
+ Hits         21673    21831     +158     
- Misses         854      888      +34     
+ Partials         9        7       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Manik2708 Manik2708 changed the title Sign up route Sign up route changed with bug fix and proper data importation Jan 31, 2024
@Cioppolo14
Copy link
Contributor

@Manik2708 Please fix the failing code coverage tests.

@Manik2708
Copy link
Contributor Author

@Manik2708 Please fix the failing code coverage tests.

Actually this is a bug fix for #1741, The files changed by me are singnUp.ts and acceptMembershipRequest.ts, and I have written tests for it, rest of the files are modified to resolve conflicts. If need is there, I can write tests for other files also, but it will require more time.

@Cioppolo14
Copy link
Contributor

@beingnoble03 @anwersayeed Can you review this PR?

@palisadoes
Copy link
Contributor

@Manik2708 please fix the conflicting file

@Manik2708
Copy link
Contributor Author

@beingnoble03 @EshaanAgg @anwersayeed Please review!

Copy link
Contributor

@EshaanAgg EshaanAgg left a comment

Choose a reason for hiding this comment

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

I can't understand the reasoning behind the UserToReturn model. The best way would be just to remove the password field from the User model in src/typeDefs/types so that the client can never request for the same. Database schema and GraphQL can be different (and in most cases they should be).

Comment on lines 287 to 304
* This is an interface of the user that will be returned to the client side.
* The differrence between this interface and the real User Interface is that it doesn't contains password field
* Although this is a poor way, a better way will include implementing this Model with inclusion of password field and then using that model everywhere.
*/
export interface InterfaceUserToReturn {
_id: Types.ObjectId;
address: {
city: string;
countryCode: string;
dependentLocality: string;
line1: string;
line2: string;
postalCode: string;
sortingCode: string;
state: string;
};
adminApproved: boolean;
adminFor: PopulatedDoc<InterfaceOrganization & Document>[];
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we creating a model for this? This is already handled in the GraphQL resolvers by adding the password: 0 argument to the database calls so that the hashed password is not fetched from the database by Mongoose.

@Manik2708
Copy link
Contributor Author

I can't understand the reasoning behind the UserToReturn model. The best way would be just to remove the password field from the User model in src/typeDefs/types so that the client can never request for the same. Database schema and GraphQL can be different (and in most cases they should be).

I also firstly tried in the same way, but User type doesn't have password field already! See this image:

Screenshot from 2024-02-07 11-57-51

But generatedGraphqltypes is taking User (GraphQL) as InterfaceUserModel which takes password as parameter. See this image:

Screenshot from 2024-02-07 12-00-20

See this also:

Screenshot from 2024-02-07 12-03-54

And that's why signUp payload is still giving password (Actually in the repo, a hack was there to skip this error by using delete operand, Graphql is not able to detect that password field is not there. Although there is no problem in it except that we have to @ts-ignore in it) See the image of signUp.payload when delete operand is not used

Screenshot from 2024-02-07 12-06-28

@Manik2708
Copy link
Contributor Author

@Manik2708

* Please fix the conflicting files so that we can review again and merge

Number of conflicts are very high. Please give me some time.

@Cioppolo14
Copy link
Contributor

@Manik2708 Please fix the conflicting files and failing tests.

@Manik2708
Copy link
Contributor Author

@palisadoes There is a doubt while changing the logic according to latest changes. Why adminApproved is still a part of AppUserProfile? Referring to this comment: #1862 (comment), this variable was to be removed. But it is not removed yet! And if it is not to be removed then how it is being used?

Another question which is there: Should user be allowed to enter Talawa Ecosystem if the membership request made by it (Please refer to PR template for the route) for the defaultOrganization is rejected? If no then again what's the use of adminApproved?

@palisadoes
Copy link
Contributor

  1. We are now approving members joining on a per-organization basis, that's why it's there.
  2. Some organizations may want to automatically approve new members which would set this flag to true by default, that's why it's still there.

@Manik2708
Copy link
Contributor Author

  1. We are now approving members joining on a per-organization basis, that's why it's there.
  2. Some organizations may want to automatically approve new members which would set this flag to true by default, that's why it's still there.

Okay, so in this PR, I am going with this logic now:

  1. If selectedOrganization requires registration, then a membership request will be made to that organization and if it is accepted adminApproved will become true.
  2. Else adminApproved will become true in signUp mutation itself.

@Olatade
Copy link

Olatade commented Mar 26, 2024

@Manik2708 please can you fix the conflicting files?

@palisadoes
Copy link
Contributor

  1. We are now approving members joining on a per-organization basis, that's why it's there.
  2. Some organizations may want to automatically approve new members which would set this flag to true by default, that's why it's still there.

Okay, so in this PR, I am going with this logic now:

1. If `selectedOrganization` requires registration, then a membership request will be made to that organization and if it is accepted `adminApproved` will become `true`.

2. Else `adminApproved` will become `true` in `signUp` mutation itself.
  1. Yes.
  2. Please fix the conflicting files.
  3. I'd like to get this reviewed and merged soon. The issue has been open for 10 weeks

@palisadoes
Copy link
Contributor

  1. Please fix the failing GitHub actions.
  2. We need to get this PR merged, it's been too long.

@palisadoes
Copy link
Contributor

  1. The setup script is out of scope of the issue.
  2. You are trying to do too many things here.
  3. Please exclude all the setup files from the PR as they don't relate to the issue. You can do this by running the commands below from the root directory of the repository
git add -u
git reset HEAD path/to/file
git commit

I'll create a separate issue to fix setup.

Focus on the original issue. This PR is taking much too long. I will soon have to close it

@Manik2708
Copy link
Contributor Author

@palisadoes Please review!

@Manik2708
Copy link
Contributor Author

Please see that tests for importDefaultOrganization can't be written. It can be tested directly in the CI, just like importSampleData.

@Manik2708
Copy link
Contributor Author

  1. The setup script is out of scope of the issue.

    1. You are trying to do too many things here.

    2. Please exclude all the setup files from the PR as they don't relate to the issue. You can do this by running the commands below from the root directory of the repository

git add -u
git reset HEAD path/to/file
git commit

I'll create a separate issue to fix setup.

Focus on the original issue. This PR is taking much too long. I will soon have to close it

The logic is implemented but the problem lies in testing them. Writing tests for yargs is not easy and will take time. I have tried my best to test the maximum but it will definitely take inputs from other contributors. Most importantly assistance from mentors is required. I will not suggest to write completely exclude setup, as already a very high time has been given to this. So I don't think other contributors should spend time in implementing logic, rather they can spend more time on testing these features and fixing the issues that may rise once this PR is merged.

@palisadoes
Copy link
Contributor

We can make the setup tests another issue. This is taking too long.
Is it ready for review now?

@Manik2708
Copy link
Contributor Author

We can make the setup tests another issue. This is taking too long. Is it ready for review now?

Yes

Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

It fails here. I already have data in the DB

image

Copy link
Contributor

@palisadoes palisadoes left a comment

Choose a reason for hiding this comment

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

The code doesn't work with the latest Admin code.

  1. The logo is missing
  2. Registration fails
  3. I imported the sample data

image

@palisadoes
Copy link
Contributor

Focus on the registration part. This is taking too long, and the basic testing hasn't been applied.

I've opened this issue to fix setup.

@palisadoes
Copy link
Contributor

I'd like to put this in context. There has been:

  1. 35 comments in the issue
  2. 130 comments in this PR
  3. 10 weeks of discussion on a relatively simple PR
  4. No resolution

In addition to this:

  1. You said the PR was ready for review, and rudimentary manual tests were not done.
  2. You have been working on other simple test PRs, ignoring this one.

I'm going to close this PR, and reassign the issue.

This is unfortunate.

@palisadoes palisadoes closed this Mar 28, 2024
@Manik2708
Copy link
Contributor Author

I'd like to put this in context. There has been:

  1. 35 comments in the issue
  2. 130 comments in this PR
  3. 10 weeks of discussion on a relatively simple PR
  4. No resolution

In addition to this:

  1. You said the PR was ready for review, and rudimentary manual tests were not done.
  2. You have been working on other simple test PRs, ignoring this one.

I'm going to close this PR, and reassign the issue.

This is unfortunate.

No problem @palisadoes. I tried but failed. I hope my efforts in this PR will help the new assignee.

@Manik2708
Copy link
Contributor Author

I'd like to put this in context. There has been:

  1. 35 comments in the issue
  2. 130 comments in this PR
  3. 10 weeks of discussion on a relatively simple PR
  4. No resolution

In addition to this:

  1. You said the PR was ready for review, and rudimentary manual tests were not done.
  2. You have been working on other simple test PRs, ignoring this one.

I'm going to close this PR, and reassign the issue.

This is unfortunate.

I never ignored this PR. Changes were so abrupt in the last month, that it was really difficult to cop-up. I always wanted to give my best that's why I picked other testing issues. I can't give the time back but can help the new assignee.

Copy link

@surajshirke160000 surajshirke160000 left a comment

Choose a reason for hiding this comment

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

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.

9 participants