From 26d7ee975eb5b1cf5bdcdc747c01b645a7d3859c Mon Sep 17 00:00:00 2001 From: jkarenzi Date: Thu, 13 Jun 2024 19:06:38 +0200 Subject: [PATCH] feat(email-integration): implement email integration - add swagger documentation [Delivers #4] --- docker-compose.test.yml | 9 ++++ src/docs/authDocs.ts | 115 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) diff --git a/docker-compose.test.yml b/docker-compose.test.yml index 8b3a1d2..2b7b5a0 100644 --- a/docker-compose.test.yml +++ b/docker-compose.test.yml @@ -4,9 +4,18 @@ services: build: context: . dockerfile: Dockerfile.test + environment: + JWT_SECRET: ${JWT_SECRET} + EMAIL: ${EMAIL} + EMAIL_PASS: ${EMAIL_PASS} + MONGO_URL: ${MONGO_URL} + DB_NAME: ${DB_NAME} depends_on: - mongo mongo: image: mongo:latest ports: - "32768:27017" + environment: + MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME} + MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD} diff --git a/src/docs/authDocs.ts b/src/docs/authDocs.ts index 4cabad7..5f257c2 100644 --- a/src/docs/authDocs.ts +++ b/src/docs/authDocs.ts @@ -57,3 +57,118 @@ * '500': * description: Internal Server Error */ + +/** + * @swagger + * api/auth/verify_email/${token}: + * get: + * summary: Verify Email + * tags: [Authentication] + * parameters: + * - in: path + * name: token + * schema: + * type: string + * required: true + * description: token + * responses: + * '200': + * description: Email successfully verified + * '409': + * description: Invalid or expired token + * '500': + * description: Internal Server Error + */ + +/** + * @swagger + * api/auth/request_new_link: + * post: + * summary: Request new verification link + * tags: [Authentication] + * security: + * - bearerAuth: [] + * responses: + * '200': + * description: Email sent successfully + * '400': + * description: User is already verified + * '500': + * description: Internal Server Error + */ + +/** + * @swagger + * api/auth/verify_code/{userId}: + * post: + * summary: Verify 2FA Code + * tags: [Authentication] + * parameters: + * - in: path + * name: userId + * schema: + * type: string + * required: true + * description: userId + * requestBody: + * required: true + * content: + * application/json: + * schema: + * type: object + * properties: + * twoFactorCode: + * type: number + * responses: + * '200': + * description: Login successful + * '409': + * description: Failed validation + * '404': + * description: User not found + * '401': + * description: Code provided does not match code sent + * '500': + * description: Internal Server Error + */ + +/** + * @swagger + * api/auth/request_new_code/{userId}: + * post: + * summary: Request new 2FA Code + * tags: [Authentication] + * parameters: + * - in: path + * name: userId + * schema: + * type: string + * required: true + * description: userId + * responses: + * '200': + * description: Email sent successfully + * '401': + * description: 2FA is not enabled + * '404': + * description: User not found + * '500': + * description: Internal Server Error + */ + +/** + * @swagger + * api/auth/toggle_2fa: + * patch: + * summary: Enable/Disable 2FA + * tags: [Authentication] + * security: + * - bearerAuth: [] + * responses: + * '200': + * description: 2FA status updated successfully + * '400': + * description: Failed validation + * '500': + * description: Internal Server Error + */ \ No newline at end of file