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

This commit is contained in:
Andrew Bastin
2023-07-11 20:03:08 +05:30
committed by GitHub
parent b2af353941
commit b29c04c28d
2 changed files with 5 additions and 3 deletions

View File

@@ -256,7 +256,9 @@ export class TeamInvitationService {
pipe( pipe(
undefined, undefined,
TE.fromPredicate( TE.fromPredicate(
(a) => acceptedBy.email === invitation.inviteeEmail, () =>
acceptedBy.email.toLowerCase() ===
invitation.inviteeEmail.toLowerCase(),
() => TEAM_INVITE_EMAIL_DO_NOT_MATCH, () => TEAM_INVITE_EMAIL_DO_NOT_MATCH,
), ),
), ),

View File

@@ -5,7 +5,6 @@ import * as O from 'fp-ts/Option';
import * as T from 'fp-ts/Task'; import * as T from 'fp-ts/Task';
import * as TE from 'fp-ts/TaskEither'; import * as TE from 'fp-ts/TaskEither';
import { GqlExecutionContext } from '@nestjs/graphql'; import { GqlExecutionContext } from '@nestjs/graphql';
import { User } from 'src/user/user.model';
import { import {
BUG_AUTH_NO_USER_CTX, BUG_AUTH_NO_USER_CTX,
BUG_TEAM_INVITE_NO_INVITE_ID, BUG_TEAM_INVITE_NO_INVITE_ID,
@@ -55,7 +54,8 @@ export class TeamInviteeGuard implements CanActivate {
// Check if the emails match // Check if the emails match
TE.chainW( TE.chainW(
TE.fromPredicate( TE.fromPredicate(
({ user, invite }) => user.email === invite.inviteeEmail, ({ user, invite }) =>
user.email.toLowerCase() === invite.inviteeEmail.toLowerCase(),
() => TEAM_INVITE_EMAIL_DO_NOT_MATCH, () => TEAM_INVITE_EMAIL_DO_NOT_MATCH,
), ),
), ),