Skip to content

Commit

Permalink
Merge pull request #37 from atlp-rwanda/fix-login-validation-#187419169
Browse files Browse the repository at this point in the history
#187419169 user can login via email and password
  • Loading branch information
teerenzo authored Apr 30, 2024
2 parents 5a449cd + 6cef0b7 commit 4f0776b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/routes/userRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { passwordUpdateSchema } from "../schemas/passwordUpdate";
import { isTokenFound } from "../middlewares/isTokenFound";
import { authenticateUser, callbackFn } from "../services/user.service";
require("../auth/auth");
import logInSchema from "../schemas/loginSchema";

const userRoutes = Router();

userRoutes.get("/", fetchAllUsers);
userRoutes.put("/passwordupdate", isLoggedIn, validateSchema(passwordUpdateSchema), updatePassword)
userRoutes.post('/login',userLogin);
userRoutes.post("/login", emailValidation,validateSchema(logInSchema),userLogin);
userRoutes.post("/register", emailValidation, validateSchema(signUpSchema), createUserController);
userRoutes.put("/passwordupdate", isLoggedIn, validateSchema(passwordUpdateSchema), updatePassword);
userRoutes.post("/2fa-verify", isTokenFound, tokenVerification);
Expand Down
8 changes: 8 additions & 0 deletions src/schemas/loginSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Joi from "joi";

export const logInSchema = Joi.object({
email: Joi.string().min(6).required().email(),
password: Joi.string().min(6).max(20).required(),
}).options({ allowUnknown: false });

export default logInSchema;

0 comments on commit 4f0776b

Please sign in to comment.