Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 4a8ff73

Browse files
authored
Make dojo invites case insensitive as they are email based (#411)
1 parent 2610e30 commit 4a8ff73

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/perm/is-own-invite.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ function isOwnInvite (args, done) {
1717
seneca.log.error(seneca.customValidatorLogFormatter('cd-dojos', 'isOwnInvite', err, {userId: userId, inviteId: inviteId, dojoId: dojoId}));
1818
return done(null, {'allowed': false});
1919
}
20-
isOwn = _.find(dojo.userInvites, {id: inviteId, email: args.user.email});
20+
if (dojo.userInvites) {
21+
const invites = dojo.userInvites.map((invite) => ({
22+
id: invite.id,
23+
// Due to dojo saving overwriting invites, the email may be null
24+
email: invite.email ? invite.email.toLowerCase() : '',
25+
}));
26+
isOwn = _.find(invites, { id: inviteId, email: args.user.email.toLowerCase() });
27+
}
2128
isOwn = !_.isEmpty(isOwn)? true: false;
2229
return done(null, {'allowed': isOwn});
2330
});

0 commit comments

Comments
 (0)