Skip to content

Commit 1d93a4e

Browse files
author
Maksym Mykhailenko
committed
fix: update and delete invited user by email
make it case-insensetive
1 parent f0fe7bf commit 1d93a4e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/routes/projectMemberInvites/delete.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = [
1616
(req, res, next) => {
1717
const projectId = _.parseInt(req.params.projectId);
1818
const inviteId = _.parseInt(req.params.inviteId);
19-
const email = req.authUser.email;
19+
const currentUserEmail = req.authUser.email ? req.authUser.email.toLowerCase() : req.authUser.email;
2020
const currentUserId = req.authUser.userId;
2121

2222
// get invite by id and project id
@@ -25,13 +25,13 @@ module.exports = [
2525
// if invite doesn't exist, return 404
2626
if (!invite) {
2727
const err = new Error(`invite not found for project id ${projectId}, inviteId ${inviteId},` +
28-
` email ${email} and userId ${currentUserId}`,
28+
` email ${currentUserEmail} and userId ${currentUserId}`,
2929
);
3030
err.status = 404;
3131
return next(err);
3232
}
3333
// check this invitation is for logged-in user or not
34-
const ownInvite = (!!invite && (invite.userId === currentUserId || invite.email === email));
34+
const ownInvite = (!!invite && (invite.userId === currentUserId || invite.email === currentUserEmail));
3535

3636
// check permission
3737
req.log.debug('Checking user permission for deleting invite');

src/routes/projectMemberInvites/update.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module.exports = [
3636
}
3737
const projectId = _.parseInt(req.params.projectId);
3838
const inviteId = _.parseInt(req.params.inviteId);
39-
const email = req.authUser.email;
39+
const currentUserEmail = req.authUser.email ? req.authUser.email.toLowerCase() : req.authUser.email;
4040
const currentUserId = req.authUser.userId;
4141

4242
// get invite by id and project id
@@ -45,13 +45,13 @@ module.exports = [
4545
// if invite doesn't exist, return 404
4646
if (!invite) {
4747
const err = new Error(`invite not found for project id ${projectId}, inviteId ${inviteId},` +
48-
` email ${email} and userId ${currentUserId}`,
48+
` email ${currentUserEmail} and userId ${currentUserId}`,
4949
);
5050
err.status = 404;
5151
return next(err);
5252
}
5353
// check this invitation is for logged-in user or not
54-
const ownInvite = (!!invite && (invite.userId === currentUserId || invite.email === email));
54+
const ownInvite = (!!invite && (invite.userId === currentUserId || invite.email === currentUserEmail));
5555

5656
// check permission
5757
req.log.debug('Checking user permission for updating invite');
@@ -103,7 +103,7 @@ module.exports = [
103103
req.context.currentProjectMembers = members;
104104
let userId = updatedInvite.userId;
105105
// if the requesting user is updating his/her own invite
106-
if (!userId && email === updatedInvite.email) {
106+
if (!userId && currentUserEmail === updatedInvite.email) {
107107
userId = currentUserId;
108108
}
109109
// if we are not able to identify the user yet, it must be something wrong and we should not create

0 commit comments

Comments
 (0)