chore: merge hoppscotch/patch into hoppscotch/next
This commit is contained in:
@@ -157,7 +157,7 @@ beforeEach(() => {
|
||||
describe('UserService', () => {
|
||||
describe('findUserByEmail', () => {
|
||||
test('should successfully return a valid user given a valid email', async () => {
|
||||
mockPrisma.user.findUniqueOrThrow.mockResolvedValueOnce(user);
|
||||
mockPrisma.user.findFirst.mockResolvedValueOnce(user);
|
||||
|
||||
const result = await userService.findUserByEmail(
|
||||
'dwight@dundermifflin.com',
|
||||
@@ -166,7 +166,7 @@ describe('UserService', () => {
|
||||
});
|
||||
|
||||
test('should return a null user given a invalid email', async () => {
|
||||
mockPrisma.user.findUniqueOrThrow.mockRejectedValueOnce('NotFoundError');
|
||||
mockPrisma.user.findFirst.mockResolvedValueOnce(null);
|
||||
|
||||
const result = await userService.findUserByEmail('jim@dundermifflin.com');
|
||||
expect(result).resolves.toBeNone;
|
||||
|
||||
@@ -62,16 +62,16 @@ export class UserService {
|
||||
* @returns Option of found User
|
||||
*/
|
||||
async findUserByEmail(email: string): Promise<O.None | O.Some<AuthUser>> {
|
||||
try {
|
||||
const user = await this.prisma.user.findUniqueOrThrow({
|
||||
where: {
|
||||
email: email,
|
||||
const user = await this.prisma.user.findFirst({
|
||||
where: {
|
||||
email: {
|
||||
equals: email,
|
||||
mode: 'insensitive',
|
||||
},
|
||||
});
|
||||
return O.some(user);
|
||||
} catch (error) {
|
||||
return O.none;
|
||||
}
|
||||
},
|
||||
});
|
||||
if (!user) return O.none;
|
||||
return O.some(user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user