From c98ca1e8c12b30322ece9cf96efad2273d766f48 Mon Sep 17 00:00:00 2001 From: Hanen Alrwasheda <alrwasheda@mi.fu-berlin.de> Date: Sun, 16 Jan 2022 04:13:26 +0100 Subject: [PATCH] email -> username according to endpoint --- server/src/controllers/auth.controllers.ts | 4 ++-- server/src/routes/auth.routes.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/src/controllers/auth.controllers.ts b/server/src/controllers/auth.controllers.ts index 073964f..cc1ed8e 100644 --- a/server/src/controllers/auth.controllers.ts +++ b/server/src/controllers/auth.controllers.ts @@ -7,12 +7,12 @@ import envVars from "../config"; //log in const authLoginController = async (req: Request, res: Response) => { try { - const { email, password } = req.body; + const { username, password } = req.body; const employee = await Employee.findOne({ attributes: ["email", "password", "role"], where: { - email: email, + email: username, }, }); diff --git a/server/src/routes/auth.routes.ts b/server/src/routes/auth.routes.ts index f6601bc..c4cce49 100644 --- a/server/src/routes/auth.routes.ts +++ b/server/src/routes/auth.routes.ts @@ -8,7 +8,7 @@ const authRouter = Router(); //log in route authRouter.post( "/api/login/", - body("email").isEmail().normalizeEmail(), + body("username").isEmail().normalizeEmail(), body("password").not().isEmpty(), handleValidationResult, authControllers.authLoginController -- GitLab