diff --git a/cdk/src/docs/userRegistration.yaml b/cdk/src/docs/userRegistration.yaml index 225055c..47c76bc 100644 --- a/cdk/src/docs/userRegistration.yaml +++ b/cdk/src/docs/userRegistration.yaml @@ -4,12 +4,6 @@ paths: summary: Register a student description: Registers a student after email verification and returns authentication tokens. parameters: - - name: email - in: query - required: true - description: The email address of the student. - schema: - type: string - name: emailVerifiedToken in: query required: true @@ -17,17 +11,21 @@ paths: schema: type: string requestBody: - description: The username and password for student registration. + description: The registration details including email and password. required: true content: application/json: schema: type: object properties: + email: + type: string + description: The email address of the student. password: type: string description: The desired password for the new student. required: + - email - password responses: '200': diff --git a/cdk/src/lambda/handlers/emailVerification.ts b/cdk/src/lambda/handlers/emailVerification.ts index 15e97a8..369ed2f 100644 --- a/cdk/src/lambda/handlers/emailVerification.ts +++ b/cdk/src/lambda/handlers/emailVerification.ts @@ -29,7 +29,7 @@ const emailVerification: APIGatewayProxyHandler = async event => { if (doesUserExist) { return errorResponse('User already exists with the provided email', 409); } - + try { const verificationCode = Math.floor(100000 + Math.random() * 900000).toString(); const redis = RedisClient.getInstance(); diff --git a/cdk/src/lambda/handlers/userRegistration.ts b/cdk/src/lambda/handlers/userRegistration.ts index 6e3174b..86df2f6 100644 --- a/cdk/src/lambda/handlers/userRegistration.ts +++ b/cdk/src/lambda/handlers/userRegistration.ts @@ -4,19 +4,19 @@ import { getEmailVerifiedToken, deleteEmailVerifiedToken } from '../../service/e import { createUserInCognito } from '../../service/cognito'; export const handler: APIGatewayProxyHandler = wrapHandler(async event => { - const email = event.queryStringParameters?.email; const emailVerifiedToken = event.queryStringParameters?.emailVerifiedToken; - if (!email || !emailVerifiedToken) { - return errorResponse('Email and email verified token are required', 400); + if (!emailVerifiedToken) { + return errorResponse('Email verified token is required', 400); } - // Get password from the request body + // Get email and password from the request body const requestBody = JSON.parse(event.body || '{}'); - const { password } = requestBody; - // Check if password is provided - if (!password) { - return errorResponse('Password is required in the request body', 400); + const { email, password } = requestBody; + + // Check if email and password are provided + if (!email || !password) { + return errorResponse('Email and password are required in the request body', 400); } // Verify the email verified token after checking email and password