From 3f45d44d9996797609a03209f2cbe8e808688262 Mon Sep 17 00:00:00 2001 From: soleil00 Date: Fri, 26 Apr 2024 17:46:48 +0200 Subject: [PATCH] Fixed missing login body in swagger doc --- src/docs/users.ts | 57 ++++++++++++++++-------- src/utils/2fa.ts | 2 +- src/utils/{verifyotp.js => verifyotp.ts} | 4 +- 3 files changed, 41 insertions(+), 22 deletions(-) rename src/utils/{verifyotp.js => verifyotp.ts} (95%) diff --git a/src/docs/users.ts b/src/docs/users.ts index 7776e09..239eef2 100644 --- a/src/docs/users.ts +++ b/src/docs/users.ts @@ -28,9 +28,9 @@ export const updatePasswordSchema = { }, confirmPassword: { type: "string", - } - } -} + }, + }, +}; export const loginSchema = { properties: { @@ -97,12 +97,34 @@ export const createUsers = { export const loginAsUser = { tags: ["Users"], summary: "Login as user", - responses: { - 200: { - description: "OK", - } - } - }; + requestBody: { + required: true, + content: { + "application/json": { + schema: { + $ref: "#/components/schemas/Login", + }, + }, + }, + }, + responses: { + 200: { + description: "OK", + }, + 400: { + description: "Bad request missing or extra filed", + }, + 404: { + description: "Account not found", + }, + 409: { + description: "Invalid credentials", + }, + 500: { + description: "Internal server error", + }, + }, +}; export const passwordUpdate = { tags: ["Users"], @@ -113,18 +135,17 @@ export const passwordUpdate = { content: { "application/json": { schema: { - $ref: "#/components/schemas/updatePassword" - } - } - } + $ref: "#/components/schemas/updatePassword", + }, + }, + }, }, responses: { 200: { description: "OK", }, 400: { - description: "Bad Request" - } - } -} - + description: "Bad Request", + }, + }, +}; diff --git a/src/utils/2fa.ts b/src/utils/2fa.ts index ee5125b..92b2566 100644 --- a/src/utils/2fa.ts +++ b/src/utils/2fa.ts @@ -1,8 +1,8 @@ import { IUser, SUBJECTS } from "../types"; import { generateMagicLinkToken, generateToken } from "../utils/jsonwebtoken"; import { env } from "../utils/env"; -const verifyOtpTemplate = require("./verifyotp"); import transporter from "./transporter"; +import { verifyOtpTemplate } from "./verifyotp"; export const sendOTP = async (user: IUser) => { try { diff --git a/src/utils/verifyotp.js b/src/utils/verifyotp.ts similarity index 95% rename from src/utils/verifyotp.js rename to src/utils/verifyotp.ts index 581c47e..5c99bec 100644 --- a/src/utils/verifyotp.js +++ b/src/utils/verifyotp.ts @@ -1,4 +1,4 @@ -const verifyOtpTemplate = (url) => { +export const verifyOtpTemplate = (url: string) => { return ` @@ -22,5 +22,3 @@ const verifyOtpTemplate = (url) => { `; }; - -module.exports = verifyOtpTemplate;