Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: email not being checked case insensitive on team invitation acceptance (#3174)

Andrew Bastinb29c04c28d6a
diff --git a/packages/hoppscotch-backend/src/team-invitation/team-invitation.service.ts b/packages/hoppscotch-backend/src/team-invitation/team-invitation.service.ts
index 98610bde1..0253d371e 100644
--- a/packages/hoppscotch-backend/src/team-invitation/team-invitation.service.ts
+++ b/packages/hoppscotch-backend/src/team-invitation/team-invitation.service.ts
@@ -256,7 +256,9 @@ export class TeamInvitationService {
pipe(
undefined,
TE.fromPredicate(
- (a) => acceptedBy.email === invitation.inviteeEmail,
+ () =>
+ acceptedBy.email.toLowerCase() ===
+ invitation.inviteeEmail.toLowerCase(),
() => TEAM_INVITE_EMAIL_DO_NOT_MATCH,
),
),
diff --git a/packages/hoppscotch-backend/src/team-invitation/team-invitee.guard.ts b/packages/hoppscotch-backend/src/team-invitation/team-invitee.guard.ts
index 1f2bdaa5d..b87615afa 100644
--- a/packages/hoppscotch-backend/src/team-invitation/team-invitee.guard.ts
+++ b/packages/hoppscotch-backend/src/team-invitation/team-invitee.guard.ts
@@ -5,7 +5,6 @@ import * as O from 'fp-ts/Option';
import * as T from 'fp-ts/Task';
import * as TE from 'fp-ts/TaskEither';
import { GqlExecutionContext } from '@nestjs/graphql';
-import { User } from 'src/user/user.model';
import {
BUG_AUTH_NO_USER_CTX,
BUG_TEAM_INVITE_NO_INVITE_ID,
@@ -55,7 +54,8 @@ export class TeamInviteeGuard implements CanActivate {
// Check if the emails match
TE.chainW(
TE.fromPredicate(
- ({ user, invite }) => user.email === invite.inviteeEmail,
+ ({ user, invite }) =>
+ user.email.toLowerCase() === invite.inviteeEmail.toLowerCase(),
() => TEAM_INVITE_EMAIL_DO_NOT_MATCH,
),
),