@@ -6,10 +6,27 @@ import { SupabaseClient } from "@supabase/supabase-js";
66
77// List all approved members
88export const listAllApprovedMembers = async ( req : Request , res : Response ) => {
9+
10+ const { email, password} = req . query ;
11+
12+ if ( email && password ) {
13+
14+ const user = await memberService . getUserByEmail ( email as string , password as string ) ;
15+
16+ if ( ! user ) throw new ApiError ( 'Incorrect email or password' , 400 ) ;
17+
18+ res . status ( 200 ) . json ( {
19+ success : true ,
20+ user
21+ } )
22+ }
23+ else {
924 const user = await memberService . approvedMembers ( ) ;
1025 res
1126 . status ( 200 )
12- . json ( { user, success : true , message : "Fetched approved users" } ) ;
27+ . json ( { user, success : true } ) ;
28+ }
29+
1330} ;
1431
1532// Get details of a single user
@@ -27,7 +44,7 @@ export const getUserDetails = async (req: Request, res: Response) => {
2744// Create a new member
2845export const createAMember =
2946 ( supabase : SupabaseClient ) => async ( req : Request , res : Response ) => {
30- const { email, name, password, passoutYear } = req . body ;
47+ const { email, name, password, passoutYear, provider } = req . body ;
3148
3249 if ( ! email || ! name || ! password || ! passoutYear ) {
3350 throw new ApiError ( "Required fields absent" , 400 ) ;
@@ -44,6 +61,7 @@ export const createAMember =
4461 password ,
4562 passoutYear ,
4663 imageUrl ,
64+ provider ,
4765 ) ;
4866
4967 if ( ! user ) throw new ApiError ( "Error creating user" , 500 ) ;
0 commit comments