feat: code level email insensitivity added
This commit is contained in:
@@ -89,12 +89,17 @@ export class AdminService {
|
|||||||
adminEmail: string,
|
adminEmail: string,
|
||||||
inviteeEmail: string,
|
inviteeEmail: string,
|
||||||
) {
|
) {
|
||||||
if (inviteeEmail == adminEmail) return E.left(DUPLICATE_EMAIL);
|
if (inviteeEmail.toLowerCase() == adminEmail.toLowerCase()) {
|
||||||
|
return E.left(DUPLICATE_EMAIL);
|
||||||
|
}
|
||||||
if (!validateEmail(inviteeEmail)) return E.left(INVALID_EMAIL);
|
if (!validateEmail(inviteeEmail)) return E.left(INVALID_EMAIL);
|
||||||
|
|
||||||
const alreadyInvitedUser = await this.prisma.invitedUsers.findFirst({
|
const alreadyInvitedUser = await this.prisma.invitedUsers.findFirst({
|
||||||
where: {
|
where: {
|
||||||
inviteeEmail: inviteeEmail,
|
inviteeEmail: {
|
||||||
|
equals: inviteeEmail,
|
||||||
|
mode: 'insensitive',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (alreadyInvitedUser != null) return E.left(USER_ALREADY_INVITED);
|
if (alreadyInvitedUser != null) return E.left(USER_ALREADY_INVITED);
|
||||||
@@ -159,7 +164,7 @@ export class AdminService {
|
|||||||
try {
|
try {
|
||||||
await this.prisma.invitedUsers.deleteMany({
|
await this.prisma.invitedUsers.deleteMany({
|
||||||
where: {
|
where: {
|
||||||
inviteeEmail: { in: inviteeEmails },
|
inviteeEmail: { in: inviteeEmails, mode: 'insensitive' },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return E.right(true);
|
return E.right(true);
|
||||||
@@ -189,6 +194,7 @@ export class AdminService {
|
|||||||
NOT: {
|
NOT: {
|
||||||
inviteeEmail: {
|
inviteeEmail: {
|
||||||
in: userEmailObjs.map((user) => user.email),
|
in: userEmailObjs.map((user) => user.email),
|
||||||
|
mode: 'insensitive',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -299,7 +299,10 @@ export class ShortcodeService implements UserDataHandler, OnModuleInit {
|
|||||||
where: userEmail
|
where: userEmail
|
||||||
? {
|
? {
|
||||||
User: {
|
User: {
|
||||||
email: userEmail,
|
email: {
|
||||||
|
equals: userEmail,
|
||||||
|
mode: 'insensitive',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
|
|||||||
@@ -75,12 +75,13 @@ export class TeamInvitationService {
|
|||||||
if (!isEmailValid) return E.left(INVALID_EMAIL);
|
if (!isEmailValid) return E.left(INVALID_EMAIL);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const teamInvite = await this.prisma.teamInvitation.findUniqueOrThrow({
|
const teamInvite = await this.prisma.teamInvitation.findFirstOrThrow({
|
||||||
where: {
|
where: {
|
||||||
teamID_inviteeEmail: {
|
inviteeEmail: {
|
||||||
inviteeEmail: inviteeEmail,
|
equals: inviteeEmail,
|
||||||
teamID: teamID,
|
mode: 'insensitive',
|
||||||
},
|
},
|
||||||
|
teamID,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -62,16 +62,16 @@ export class UserService {
|
|||||||
* @returns Option of found User
|
* @returns Option of found User
|
||||||
*/
|
*/
|
||||||
async findUserByEmail(email: string): Promise<O.None | O.Some<AuthUser>> {
|
async findUserByEmail(email: string): Promise<O.None | O.Some<AuthUser>> {
|
||||||
try {
|
const user = await this.prisma.user.findFirst({
|
||||||
const user = await this.prisma.user.findUniqueOrThrow({
|
where: {
|
||||||
where: {
|
email: {
|
||||||
email: email,
|
equals: email,
|
||||||
|
mode: 'insensitive',
|
||||||
},
|
},
|
||||||
});
|
},
|
||||||
return O.some(user);
|
});
|
||||||
} catch (error) {
|
if (!user) return O.none;
|
||||||
return O.none;
|
return O.some(user);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user