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

Backend Release to Main [1.83] #1011

Merged
merged 76 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
d58a773
Bump semver from 5.7.1 to 5.7.2
dependabot[bot] Jul 11, 2023
5c9da8c
test: Ensure getUser returns 200, with the requestor body
Pandani07 Mar 27, 2024
aa76fbe
test: Returns error 400 if there is no email or password
Pandani07 Mar 27, 2024
24d85f2
test: Returns error 403 if there is no user
Pandani07 Mar 28, 2024
9e2c5dd
test: Returns error 403 if the user exists but is not active
Pandani07 Mar 28, 2024
ce984d2
test: Returns error 403 if the user exists but is not active
Pandani07 Mar 29, 2024
5235040
test: Returns error 403 if password does not match and user exists
Pandani07 Apr 1, 2024
8c254df
test: Ensure login returns error 403 if the password is not a match a…
Pandani07 Apr 20, 2024
de8ced9
test: Ensure login returns error 200 if the user is a new user and th…
Pandani07 Apr 25, 2024
54bf77d
test: Ensure login returns error 200 if the user is a new user and th…
Pandani07 Apr 25, 2024
cb96468
test: Ensure login returns error 200 if the user is a new user and th…
Pandani07 Apr 27, 2024
c9e898b
test: Ensure login returns error 200 if the user is a new user and th…
Pandani07 Apr 27, 2024
35f9004
Merge branch 'development' into Anirudh_loginmethod_unittest
Pandani07 Apr 27, 2024
8c67940
Added rout for equipment purchase
pshereen Apr 29, 2024
790419c
add package-log.json
cgomezhub May 1, 2024
a18dba4
add package.json
cgomezhub May 1, 2024
e70dbd4
add sanitize to package.jsom
cgomezhub May 2, 2024
6fe343f
Merge branch 'development' of https://github.com/OneCommunityGlobal/H…
cgomezhub May 6, 2024
2f3b037
Merge branch 'development' of https://github.com/OneCommunityGlobal/H…
cgomezhub May 7, 2024
a38518e
Updated Equipment Controller and router
pshereen May 8, 2024
ff771a5
Removed console log
pshereen May 8, 2024
2f42663
added updateSummaryRequirements permission
ImzIssa May 9, 2024
f1fa1fd
added updateSummaryRequirements permission check in profile controller
ImzIssa May 10, 2024
a2c247d
Merge branch 'development' of https://github.com/OneCommunityGlobal/H…
cgomezhub May 13, 2024
e03bca5
updating
cgomezhub May 16, 2024
8ca5882
Merge branch 'development' of https://github.com/OneCommunityGlobal/H…
cgomezhub May 20, 2024
5758f0e
Update backend canRequestorUpdateUser logic
ptrpengdev May 26, 2024
9a0d66b
Create log tracing when protected account is updated/deleted
ptrpengdev May 26, 2024
a1b9dca
Resolved merge conflicts
cgomezhub May 26, 2024
3536c82
Add unit testing cases for updated canRequestorUpdateUser function
ptrpengdev May 26, 2024
9d827c9
Update usage of canRequestorUpdateUser in userProfileController
ptrpengdev May 26, 2024
b69a864
Update unit testing file for Permission
ptrpengdev May 27, 2024
2571603
Update Cache TTL for Protected User Info and add audit log for protec…
ptrpengdev May 28, 2024
23cf9ed
add firstName and lastName to TimeEntrySchema
cgomezhub May 30, 2024
bc75aa8
add firstName and lastName to timeEntryController
cgomezhub May 30, 2024
a3a3541
Carlos_Add_Hours_by_Team_Member_Visualization_Project_Reports
cgomezhub May 31, 2024
5da2160
update npm
cgomezhub May 31, 2024
7eaf19f
npm install
cgomezhub May 31, 2024
5fec999
updated babel-plugin
cgomezhub Jun 1, 2024
153808f
updated babel-plugin
cgomezhub Jun 1, 2024
8e42b27
update check permission
Jun 4, 2024
96bdb03
update check permission
Jun 4, 2024
8785863
Merge branc 'development' of https://github.com/OneCommunityGlobal/HG…
cgomezhub Jun 5, 2024
5d68af8
Merge branch 'development' of https://github.com/OneCommunityGlobal/H…
cgomezhub Jun 6, 2024
c8a500c
Merge branch 'development' into Carlos_Add_Hours_by_Team_Member_Visua…
cgomezhub Jun 6, 2024
3d86060
update package-lock
cgomezhub Jun 6, 2024
479651a
update with newest code
Jun 7, 2024
1e82142
update with develpment code to resolve conflicts
Jun 7, 2024
4221876
Update on email notification for protected account update/delete oper…
ptrpengdev Jun 8, 2024
8ab7620
Merge remote-tracking branch 'origin' into Jingyi_create/edit/delete_…
jingyij Jun 11, 2024
d6bd5b8
chore: fix merge issues
Abi-Liu Jun 12, 2024
0958c72
Update object comparator and audit logs for protected account activity
ptrpengdev Jun 15, 2024
453c65f
Merge branch 'development' into Imran_Edit_Summary_Submit_Requirement…
ImzIssa Jun 15, 2024
985d2ea
Merge branch 'development' into Jingyi_create/edit/delete_badges_perm…
Jingyii800 Jun 18, 2024
530848f
Merge branch 'development' into Carlos_Add_Hours_by_Team_Member_Visua…
cgomezhub Jun 20, 2024
9dd3b72
update packages
cgomezhub Jun 20, 2024
fc34ae2
update packages
cgomezhub Jun 20, 2024
01313f9
Merge pull request #942 from OneCommunityGlobal/Imran_Edit_Summary_Su…
one-community Jun 22, 2024
2ab7527
Merge pull request #439 from OneCommunityGlobal/dependabot/npm_and_ya…
EvianTan Jun 22, 2024
74da28a
Merge pull request #974 from OneCommunityGlobal/Jingyi_create/edit/de…
one-community Jun 23, 2024
a68a041
Merge branch 'development' of github.com:OneCommunityGlobal/HGNRest i…
ptrpengdev Jun 23, 2024
9ecd01a
Update Permission control
ptrpengdev Jun 23, 2024
1c1dd82
Update Auditing feature
ptrpengdev Jun 23, 2024
1df61fe
Fix a minor bug in canRequestorUpdateUser
ptrpengdev Jun 23, 2024
5f0dbb1
Merge pull request #963 from OneCommunityGlobal/shengwei_add_protecti…
one-community Jun 23, 2024
0bc6bae
Merge branch 'development' into Carlos_Add_Hours_by_Team_Member_Visua…
cgomezhub Jun 26, 2024
daaa5f5
Update package-lock.json
cgomezhub Jun 26, 2024
7e23df9
Merge pull request #972 from OneCommunityGlobal/Carlos_Add_Hours_by_T…
one-community Jun 26, 2024
8cc079d
Merge branch 'development' of https://github.com/OneCommunityGlobal/H…
pshereen Jun 27, 2024
8cf6787
Purchase Equipment
pshereen Jun 27, 2024
ffda0b9
Merge pull request #946 from OneCommunityGlobal/Shereen_Purchase_Equi…
one-community Jun 28, 2024
b60e77f
Revert "Shereen purchase equipment"
one-community Jun 29, 2024
a2d126e
Merge pull request #1008 from OneCommunityGlobal/revert-946-Shereen_P…
one-community Jun 29, 2024
0d0c9b5
Revert "Carlos add hours by team member visualization project reports"
one-community Jun 29, 2024
75b3b1f
Merge pull request #1009 from OneCommunityGlobal/revert-972-Carlos_Ad…
one-community Jun 29, 2024
9bd36d1
Merge pull request #912 from OneCommunityGlobal/Anirudh_loginmethod_u…
one-community Jun 29, 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
54 changes: 27 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions requirements/logincontroller/getUser-usecase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Check mark: ✅
Cross Mark: ❌

# GetUser

> ## Positive case

1. ❌ Receives a POST request in the **/api/userProfile** route
2. ✅ Returns **200**, with the requestor body
21 changes: 21 additions & 0 deletions requirements/logincontroller/login-usecase.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Check mark: ✅
Cross Mark: ❌

# login

> ## Positive case

1. ❌ Receives a POST request in the **/api/userProfile** route
2. ✅ Returns 200, if the user is a new user and there is a password match
3. ✅ Returns 200, if the user already exists and the password is a match

## Negative case

1. ✅ Returns error 400 if there is no email or password
2. ✅ Returns error 403 if there is no user
3. ✅ Returns error 403 if the user exists but is not active
4. ✅ Returns error 403 if the password is not a match and if the user already exists - in progress

## Edge case

1. ✅ Returns the error if the try block fails - in progress
15 changes: 12 additions & 3 deletions src/controllers/badgeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,21 @@ const badgeController = function (Badge) {
const cache = cacheClosure();

const getAllBadges = async function (req, res) {
console.log(req.body.requestor);
if (!(await helper.hasPermission(req.body.requestor, 'seeBadges'))) {
console.log('in if statement');
console.log(req.body.requestor); // Retain logging from development branch for debugging

// Check if the user has any of the following permissions
if (
!(await helper.hasPermission(req.body.requestor, 'seeBadges')) &&
!(await helper.hasPermission(req.body.requestor, 'assignBadges')) &&
!(await helper.hasPermission(req.body.requestor, 'createBadges')) &&
!(await helper.hasPermission(req.body.requestor, 'updateBadges')) &&
!(await helper.hasPermission(req.body.requestor, 'deleteBadges'))
) {
console.log('in if statement'); // Retain logging from development branch for debugging
res.status(403).send('You are not authorized to view all badge data.');
return;
}

// Add cache to reduce database query and optimize performance
if (cache.hasCache('allBadges')) {
res.status(200).send(cache.getCache('allBadges'));
Expand Down
66 changes: 34 additions & 32 deletions src/controllers/logincontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const logincontroller = function () {
if (!user) {
res.status(403).send({ message: 'Username not found.' });
} else if (user.isActive === false) {
res.status(403).send({ message: 'Sorry, this account is no longer active. If you feel this is in error, please contact your Manager and/or Administrator.' });
res.status(403).send({
message:
'Sorry, this account is no longer active. If you feel this is in error, please contact your Manager and/or Administrator.',
});
} else {
let isPasswordMatch = false;
let isNewUser = false;
Expand All @@ -34,42 +37,42 @@ const logincontroller = function () {
isPasswordMatch = await bcrypt.compare(_password, user.password);

if (!isPasswordMatch && user.resetPwd !== '') {
isPasswordMatch = (_password === user.resetPwd);
isPasswordMatch = _password === user.resetPwd;
isNewUser = true;
}

if (isNewUser && isPasswordMatch) {
const result = {
new: true,
userId: user._id,
};
res.status(200).send(result);
} else if (isPasswordMatch && !isNewUser) {
const jwtPayload = {
userid: user._id,
role: user.role,
permissions: user.permissions,
access: {
canAccessBMPortal: false,
},
email: user.email,
expiryTimestamp: moment().add(config.TOKEN.Lifetime, config.TOKEN.Units),
};
if (isNewUser && isPasswordMatch) {
const result = {
new: true,
userId: user._id,
};
res.status(200).send(result);
} else if (isPasswordMatch && !isNewUser) {
const jwtPayload = {
userid: user._id,
role: user.role,
permissions: user.permissions,
access: {
canAccessBMPortal: false,
},
email: user.email,
expiryTimestamp: moment().add(config.TOKEN.Lifetime, config.TOKEN.Units),
};

const token = jwt.sign(jwtPayload, JWT_SECRET);
const token = jwt.sign(jwtPayload, JWT_SECRET);

res.status(200).send({ token });
} else {
res.status(403).send({
message: 'Invalid password.',
});
}
res.status(200).send({ token });
} else {
res.status(403).send({
message: 'Invalid password.',
});
}
}
} catch (err) {
console.log(err);
res.json(err);
}
};
} catch (err) {
console.log(err);
res.json(err);
}
};

const getUser = function (req, res) {
const { requestor } = req.body;
Expand All @@ -78,7 +81,6 @@ const logincontroller = function () {
};

return {

login,
getUser,
};
Expand Down
Loading
Loading