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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
d606e28
Signup route changed
Jan 24, 2024
026744d
Formatting done
Jan 24, 2024
6ee8381
Schemas fix
Jan 24, 2024
be1b39b
Setup File edited
Jan 24, 2024
d0348de
Setup Route Changed
Jan 25, 2024
8021cb1
Fix as per the need
Jan 26, 2024
8452ede
Setup file working finally
Jan 26, 2024
9e5389a
Merge branch 'develop' into SignUpRoute
Manik2708 Jan 26, 2024
0790722
Linting fix
Jan 27, 2024
d4baf30
Merge branch 'develop' into SignUpRoute
Manik2708 Jan 28, 2024
91932f4
Conflicts fix
Jan 28, 2024
62cf9e0
Type Errors fixed
Jan 28, 2024
2002b50
Type Errors fixed
Jan 28, 2024
a7a10c0
Signup route changed with bug fix
Jan 31, 2024
48ddeb4
Merge branch 'develop' into SignUpRoute
Manik2708 Feb 4, 2024
4a9002f
Model changes
Feb 12, 2024
07bff88
Model changes
Feb 12, 2024
279ac6a
Linting fixed
Feb 12, 2024
bf61349
Sample data fix
Feb 12, 2024
5684ca4
Conflicts fix try
Feb 12, 2024
2761041
Linting
Feb 13, 2024
ddb114a
Linting
Feb 13, 2024
53cbec7
Linting
Feb 13, 2024
c30008c
Linting
Feb 13, 2024
5996b7b
Merge branch 'develop' into SignUpRoute
Manik2708 Feb 20, 2024
3d2cd31
Admin approved route discarded
Feb 20, 2024
e0855ee
Merge branch 'develop' into SignUpRoute
Manik2708 Feb 20, 2024
9a55d63
Merge branch 'develop' into SignUpRoute
Manik2708 Feb 24, 2024
c788c9a
Merge branch 'develop' into SignUpRoute
Manik2708 Feb 25, 2024
eec0d0e
Merge branch 'develop' into SignUpRoute
Manik2708 Mar 2, 2024
9fd1df5
Linting fix
Mar 2, 2024
42d0ddf
Tests fixed
Mar 2, 2024
96bf952
Tests fixed
Mar 2, 2024
7880bdf
Tests fixed
Mar 2, 2024
a4a88d1
Tests fixed
Mar 2, 2024
45308ec
Tests fixed
Mar 2, 2024
ac791a5
Merge branch 'develop' into SignUpRoute
palisadoes Mar 3, 2024
42324e7
Merge branch 'develop' into SignUpRoute
palisadoes Mar 4, 2024
4a470c3
Requested Changes
Mar 5, 2024
5c5cbfc
Merge branch 'develop' into SignUpRoute
Manik2708 Mar 5, 2024
7584fdf
Requested Changes
Mar 6, 2024
f542c0f
Merge branch 'develop' into SignUpRoute
palisadoes Mar 6, 2024
b088ea8
tests fix
Mar 6, 2024
585a18b
tests fix
Mar 6, 2024
2f2c947
tests fix
Mar 6, 2024
4e7cdac
tests fix
Mar 6, 2024
1bc4a5f
tests fix
Mar 6, 2024
f0bb3e2
Merge branch 'develop' into SignUpRoute
Manik2708 Mar 6, 2024
3436579
tests fix
Mar 6, 2024
094c48a
tests fix
Mar 8, 2024
e2b5b28
tests fix
Mar 8, 2024
6d4fb1e
data change
Mar 9, 2024
58a90dd
Merge branch 'develop' into SignUpRoute
Manik2708 Mar 10, 2024
023b6d1
tests added
Mar 13, 2024
0cc0c18
Merge branch 'develop' into SignUpRoute
Manik2708 Mar 13, 2024
07191e6
tests added
Mar 13, 2024
8b657b2
tests added
Mar 14, 2024
c77bee6
bug fix
Mar 15, 2024
075ed40
Merge branch 'develop' into SignUpRoute
Manik2708 Mar 27, 2024
75457aa
Final logic
Mar 27, 2024
e716073
Merge branch 'develop' into SignUpRoute
Manik2708 Mar 27, 2024
344ca49
Reverting husky
Mar 27, 2024
f2342df
Reverting husky
Mar 27, 2024
5ab6096
Reverting husky
Mar 27, 2024
e2b6800
Merge branch 'develop' into SignUpRoute
Manik2708 Mar 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,249 changes: 705 additions & 544 deletions docs/Schema.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"generate:graphql-schema": "get-graphql-schema http://localhost:4000/graphql --json > docs/schema.json",
"generate:ssl-private-key": "openssl genrsa -out ./key.pem",
"import:sample-data": "tsx ./src/utilities/loadSampleData.ts",
"import:sample-data-defaultOrg": "tsx ./src/utilities/loadDefaultOrganizationScript.ts",
"import:sample-data:prod": "node ./build/utilities/loadSampleData.js",
"gen:schema": "graphql-inspector introspect ./src/typeDefs/**/**/*.ts --write ./schema.graphql ",
"update:toc": "node scripts/githooks/update-toc.js"
Expand Down
31 changes: 31 additions & 0 deletions sample_data/defaultOrganization.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[
{
"_id": "65ecb98712e5d1c5a4504ce4",
"status": "ACTIVE",
"members": ["65ecb93989225c818f784821"],
"admins": ["65ecb93989225c818f784821"],
"groupChats": [],
"posts": [],
"pinnedPosts": [],
"membershipRequests": [],
"blockedUsers": [],
"name": "Default Organization",
"description": "Default description. Needs to be changed.",
"address": {
"city": "Default Address. Needs to be changed",
"countryCode": "IN",
"dependentLocality": "Default Address. Needs to be changed",
"line1": "default1",
"line2": "default2",
"postalCode": "711205",
"sortingCode": "default sorting code",
"state": "default state"
},
"userRegistrationRequired": false,
"visibleInSearch": true,
"image": null,
"creatorId": "65ecb93989225c818f784821",
"createdAt": "2023-04-13T05:16:52.827Z",
"__v": 0
}
]
19 changes: 19 additions & 0 deletions sample_data/defaultOrganizationAdmin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[
{
"_id": "65ecb93989225c818f784821",
"appUserProfileId": "66043dbcd72afa8f13db5854",
"joinedOrganizations": ["65ecb98712e5d1c5a4504ce4"],
"registeredEvents": [],
"membershipRequests": [],
"organizationsBlockedBy": [],
"status": "ACTIVE",
"pluginCreationAllowed": true,
"firstName": "Default",
"lastName": "Admin",
"email": "[email protected]",
"password": "$2a$12$bSYpay6TRMpTOaAmYPFXku4avwmqfFBtmgg39TabxmtFEiz4plFtW",
"image": null,
"createdAt": "2023-04-13T04:53:17.742Z",
"__v": 0
}
]
18 changes: 18 additions & 0 deletions sample_data/defaultOrganizationAdminProfileId.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[
{
"_id": "66043dbcd72afa8f13db5854",
"userId": "65ecb93989225c818f784821",
"adminFor": ["65ecb98712e5d1c5a4504ce4"],
"appLanguageCode": "en",
"createdEvents": [],
"createdOrganizations": ["65ecb98712e5d1c5a4504ce4"],
"eventAdmin": [],
"pluginCreationAllowed": true,
"token": null,
"tokenVersion": 0,
"isSuperAdmin": false,
"adminApproved": true,
"createdAt": "2023-04-13T04:53:17.742Z",
"__v": 0
}
]
2 changes: 1 addition & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -1727,8 +1727,8 @@ input UserInput {
email: EmailAddress!
firstName: String!
lastName: String!
organizationUserBelongsToId: ID
password: String!
selectedOrgainzation: ID!
}

enum UserOrderByInput {
Expand Down
15 changes: 8 additions & 7 deletions setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@ import {
checkExistingRedis,
checkRedisConnection,
} from "./src/setup/redisConfiguration";
import { askForSuperAdminEmail } from "./src/setup/superAdmin";
import { updateEnvVariable } from "./src/setup/updateEnvVariable";
import { verifySmtpConnection } from "./src/setup/verifySmtpConnection";
import { importDefaultOrganization } from "./src/setup/importDefaultOrganization";
import {
setImageUploadSize,
validateImageFileSize,
} from "./src/setup/setImageUploadSize";
import { askForSuperAdminEmail } from "./src/setup/superAdmin";
import { updateEnvVariable } from "./src/setup/updateEnvVariable";
import { verifySmtpConnection } from "./src/setup/verifySmtpConnection";
/* eslint-enable */

dotenv.config();
Expand Down Expand Up @@ -566,7 +567,6 @@ export async function twoFactorAuth(): Promise<void> {
updateEnvVariable(config);
}
}

/**
* The function `configureSmtp` prompts the user to configure SMTP settings for sending emails through
* Talawa and saves the configuration in a .env file.
Expand Down Expand Up @@ -910,8 +910,6 @@ async function main(): Promise<void> {
},
]);

await setImageUploadSize(imageSizeLimit * 1000);

if (!isDockerInstallation) {
const { shouldRunDataImport } = await inquirer.prompt([
{
Expand All @@ -921,12 +919,15 @@ async function main(): Promise<void> {
default: false,
},
]);

if (shouldRunDataImport) {
await importData();
} else {
await importDefaultOrganization();
}
}

await setImageUploadSize(imageSizeLimit * 1000);

console.log(
"\nCongratulations! Talawa API has been successfully setup! 🥂🎉",
);
Expand Down
6 changes: 4 additions & 2 deletions src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import { checkReplicaSet } from "./utilities/checkReplicaSet";

let session!: mongoose.ClientSession;

export const connect = async (): Promise<void> => {
export const connect = async (dbName?: string): Promise<void> => {
try {
await mongoose.connect(MONGO_DB_URL as string);
await mongoose.connect(MONGO_DB_URL as string, {
dbName,
});
const replicaSet = await checkReplicaSet();
if (replicaSet) {
logger.info("Session started --> Connected to a replica set!");
Expand Down
47 changes: 31 additions & 16 deletions src/resolvers/Mutation/acceptMembershipRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import type { MutationResolvers } from "../../types/generatedGraphQLTypes";
import { errors, requestContext } from "../../libraries";
import { adminCheck } from "../../utilities";
import type { Types } from "mongoose";
import { MembershipRequest, Organization, User } from "../../models";
import {
AppUserProfile,
MembershipRequest,
Organization,
User,
} from "../../models";
import {
MEMBERSHIP_REQUEST_NOT_FOUND_ERROR,
USER_ALREADY_MEMBER_ERROR,
Expand All @@ -21,6 +26,7 @@ import { cacheOrganizations } from "../../services/OrganizationCache/cacheOrgani
* 3. Whether the user exists
* 4. whether currentUser with _id === context.userId is an admin of organization.
* 5. Whether user is already a member of organization.
* 6. Whether the user is a new user or not
*/
export const acceptMembershipRequest: MutationResolvers["acceptMembershipRequest"] =
async (_parent, args, context) => {
Expand Down Expand Up @@ -102,22 +108,31 @@ export const acceptMembershipRequest: MutationResolvers["acceptMembershipRequest

if (updatedOrganization !== null) {
await cacheOrganizations([updatedOrganization]);
}

// Update the user
await User.updateOne(
{
_id: user._id,
},
{
$push: {
joinedOrganizations: organization._id,
await User.updateOne(
{
_id: user._id,
},
$pull: {
membershipRequests: membershipRequest._id,
{
$push: {
joinedOrganizations: organization._id,
},
$pull: {
membershipRequests: membershipRequest._id,
},
},
},
);

);
// Check if this request was made during signup
const appUserProfile = await AppUserProfile.findOne({
userId: user._id,
})
.select("adminApproved")
.lean();
// No need to check whether appUserProfile exists or not because if it doessn't exists, adminCheck will throw error.
if (appUserProfile?.adminApproved == false) {
await AppUserProfile.findByIdAndUpdate(appUserProfile._id, {
adminApproved: true,
});
}
}
return membershipRequest;
};
Loading
Loading