Skip to content

Commit

Permalink
fix(api): handle few undefined variables in classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sws2apps-admin authored Dec 4, 2022
1 parent 6cb6c3e commit 6ce965b
Show file tree
Hide file tree
Showing 8 changed files with 14,960 additions and 8,571 deletions.
23,489 changes: 14,933 additions & 8,556 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@
"author": "",
"license": "ISC",
"type": "module",
"eslintConfig": {
"extends": [
"react-app"
]
},
"dependencies": {
"@fingerprintjs/fingerprintjs-pro-server-api": "^1.4.0",
"@logtail/node": "^0.1.14",
Expand Down Expand Up @@ -44,6 +49,8 @@
"devDependencies": {
"@semantic-release/changelog": "^6.0.2",
"@semantic-release/git": "^10.0.1",
"eslint": "^8.29.0",
"eslint-config-react-app": "^7.0.1",
"find-unused-exports": "^5.0.0",
"nodemon": "^2.0.20"
}
Expand Down
2 changes: 1 addition & 1 deletion src/classes/Announcements.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class clsAnnouncements {
await announcementRef.delete();
}

const newList = list.filter((announcement) => announcement.id !== id);
const newList = this.list.filter((announcement) => announcement.id !== id);
this.list = newList;
return newList;
};
Expand Down
16 changes: 11 additions & 5 deletions src/classes/Congregation.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { FieldValue, getFirestore } from "firebase-admin/firestore";
import randomstring from "randomstring";
import { decryptData, encryptData } from "../utils/encryption-utils.js";
import { Congregations } from "./Congregations.js";
import { Users } from "./Users.js";

const db = getFirestore(); //get default database
Expand Down Expand Up @@ -125,7 +126,8 @@ export class Congregation {
const userRef = db.collection("users").doc(userId);
await userRef.update({ congregation: FieldValue.delete() });

await this.loadDetails();
await Users.loadAll()
await Congregations.loadAll()
};

addUser = async (userId) => {
Expand All @@ -138,7 +140,8 @@ export class Congregation {

await db.collection("users").doc(userId).set(data, { merge: true });

await this.loadDetails();
await Users.loadAll()
await Congregations.loadAll()
};

updateUserRole = async (userId, userRole) => {
Expand All @@ -151,7 +154,8 @@ export class Congregation {

await db.collection("users").doc(userId).set(data, { merge: true });

await this.loadDetails();
await Users.loadAll()
await Congregations.loadAll()
};

createPocketUser = async (pocketName, pocketId) => {
Expand All @@ -173,7 +177,8 @@ export class Congregation {
},
});

await this.loadDetails();
await Users.loadAll()
await Congregations.loadAll()

return code;
};
Expand Down Expand Up @@ -226,6 +231,7 @@ export class Congregation {
cong_sourceMaterial: newSource,
});

await this.loadDetails(this.id);
await Users.loadAll()
await Congregations.loadAll()
};
}
12 changes: 6 additions & 6 deletions src/classes/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { FieldValue, getFirestore } from "firebase-admin/firestore";
import * as OTPAuth from "otpauth";
import randomstring from "randomstring";
import { decryptData, encryptData } from "../utils/encryption-utils.js";
import { sendUserResetPassword } from "../utils/sendEmail.js";
import { sendUserResetPassword, sendVerificationEmail } from "../utils/sendEmail.js";
import { Congregations } from "./Congregations.js";
import { Users } from "./Users.js";

Expand Down Expand Up @@ -282,7 +282,8 @@ export class User {
assignCongregation = async (congInfo) => {
try {
await db.collection("users").doc(this.id).set(congInfo, { merge: true });
await this.loadDetails(id);

await Users.loadAll()
await Congregations.loadAll();
} catch (err) {
throw new Error(err.message);
Expand All @@ -309,7 +310,7 @@ export class User {

resetPassword = async () => {
const resetLink = await getAuth().generatePasswordResetLink(this.user_uid);
sendUserResetPassword(this.user_uid, user.username, resetLink);
sendUserResetPassword(this.user_uid, this.username, resetLink);
};

revokeToken = async () => {
Expand Down Expand Up @@ -341,7 +342,7 @@ export class User {
};
await db.collection("users").doc(this.id).update(data);

await this.loadDetails();
await Users.loadAll();
};

makeAdmin = async () => {
Expand Down Expand Up @@ -369,8 +370,7 @@ export class User {

await db.collection("users").doc(this.id).update({ "congregation.devices": updatedDevices });

await this.loadDetails();

await Users.loadAll()
await Congregations.loadAll();
};

Expand Down
2 changes: 1 addition & 1 deletion src/middleware/sws-pocket-auth-checker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// dependencies
import { check, validationResult } from "express-validator";
import { Users } from "../classes/Users.js";

export const pocketAuthChecker = () => {
return async (req, res, next) => {
Expand Down
2 changes: 1 addition & 1 deletion src/middleware/visitor-checker.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const visitorChecker = () => {
const user = await Users.findUserByEmail(email);

if (user) {
const { id, disabled } = user;
const { disabled } = user;

// remove expired sessions
await user.removeExpiredSession();
Expand Down
1 change: 0 additions & 1 deletion src/routes/public.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import express from "express";
import { check } from "express-validator";
import { getSchedules } from "../controllers/public-controller.js";

const router = express.Router();
Expand Down

0 comments on commit 6ce965b

Please sign in to comment.