feat: ignore case for email (#5754)

fix #5738
This commit is contained in:
DarkSky
2024-02-01 05:05:16 +00:00
parent 349f7c3f15
commit 1db8019292
5 changed files with 46 additions and 18 deletions

View File

@@ -244,7 +244,10 @@ export const NextAuthOptionsProvider: FactoryProvider<NextAuthOptions> = {
.count({
where: {
user: {
email,
email: {
equals: email,
mode: 'insensitive',
},
},
feature: {
feature: FeatureType.EarlyAccess,

View File

@@ -107,7 +107,10 @@ export class NextAuthController {
if (email) {
const user = await this.prisma.user.findFirst({
where: {
email,
email: {
equals: email,
mode: 'insensitive',
},
},
});
if (!user) {

View File

@@ -151,7 +151,10 @@ export class AuthService {
async signIn(email: string, password: string): Promise<User> {
const user = await this.prisma.user.findFirst({
where: {
email,
email: {
equals: email,
mode: 'insensitive',
},
},
});
@@ -179,7 +182,10 @@ export class AuthService {
async signUp(name: string, email: string, password: string): Promise<User> {
const user = await this.prisma.user.findFirst({
where: {
email,
email: {
equals: email,
mode: 'insensitive',
},
},
});
@@ -213,7 +219,10 @@ export class AuthService {
async createAnonymousUser(email: string): Promise<User> {
const user = await this.prisma.user.findFirst({
where: {
email,
email: {
equals: email,
mode: 'insensitive',
},
},
});
@@ -241,9 +250,12 @@ export class AuthService {
}
async getUserByEmail(email: string): Promise<User | null> {
return this.prisma.user.findUnique({
return this.prisma.user.findFirst({
where: {
email,
email: {
equals: email,
mode: 'insensitive',
},
},
});
}
@@ -251,7 +263,10 @@ export class AuthService {
async isUserHasPassword(email: string): Promise<boolean> {
const user = await this.prisma.user.findFirst({
where: {
email,
email: {
equals: email,
mode: 'insensitive',
},
},
});
if (!user) {
@@ -261,9 +276,12 @@ export class AuthService {
}
async changePassword(email: string, newPassword: string): Promise<User> {
const user = await this.prisma.user.findUnique({
const user = await this.prisma.user.findFirst({
where: {
email,
email: {
equals: email,
mode: 'insensitive',
},
emailVerified: {
not: null,
},

View File

@@ -50,7 +50,10 @@ export class FeatureManagementService {
async isEarlyAccessUser(email: string) {
const user = await this.prisma.user.findFirst({
where: {
email,
email: {
equals: email,
mode: 'insensitive',
},
},
});
if (user) {

View File

@@ -7,13 +7,14 @@ export class UsersService {
constructor(private readonly prisma: PrismaService) {}
async findUserByEmail(email: string) {
return this.prisma.user
.findUnique({
where: { email },
})
.catch(() => {
return null;
});
return this.prisma.user.findFirst({
where: {
email: {
equals: email,
mode: 'insensitive',
},
},
});
}
async findUserById(id: string) {