Skip to content

Commit d4c5658

Browse files
committed
Added more fields for authentication
1 parent cb1a851 commit d4c5658

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

src/controllers/member.controller.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,18 @@ import * as memberService from "../services/member.service";
33
import { ApiError } from "../utils/apiError";
44
import { deleteImage, uploadImage } from "../utils/imageUtils";
55
import { SupabaseClient } from "@supabase/supabase-js";
6+
import { password } from "bun";
67

78
// List all approved members
89
export const listAllApprovedMembers = async (req: Request, res: Response) => {
910

10-
const {email} = req.query;
11+
const {email, password} = req.query;
1112

1213
if(email) {
1314

14-
const user = await memberService.getUserByEmail(email as string);
15+
const user = await memberService.getUserByEmail(email as string, password as string);
1516

16-
if(!user) throw new ApiError('Incorrect email', 400);
17+
if(!user) throw new ApiError('Incorrect email or password', 400);
1718

1819
res.status(200).json({
1920
success: true,

src/services/member.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import { prisma } from "../db/client";
22
import { ApiError } from "../utils/apiError";
33

4-
export const getUserByEmail = async(email: string) => {
4+
export const getUserByEmail = async(email: string, hashedPassword: string) => {
55
return await prisma.member.findUnique({
66
where: {
77
email: email
88
},
99
select: {
1010
id: true,
11+
isApproved: true,
12+
isManager: true,
1113
accounts: {
1214
where: {
1315
provider: 'credentials',
14-
},
15-
select: {
16-
password: true,
16+
password: hashedPassword,
1717
},
1818
},
1919
}

0 commit comments

Comments
 (0)