'How do I make a user access the register page and the login page using joi without using ejs or html
I am stuck in making a user to access the register and login page in joi without using ejs or html. Below are the codes
const express = require("express");
const Joi = require("joi");
const app = express();
const schema = Joi.object({
email: Joi.string().email().required(),
password: Joi.string().min(4).alphanum().required(),
firstname: Joi.string().alphanum().required(),
lastname: Joi.string().alphanum().required()
})
app.post("/register", async(req,res) => {
if(err) {
console.log(err);
} else{
res.send("Success");
}
try{
const value = await schema.validateAsync({
email:req.body.email,
password: req.body.password,
firstname: req.body.firstname,
lastname: req.body.lastname
})
} catch(e){
console.log(e);
}
})
app.listen(3000, function(){
console.log("Listening on port 3000");
})
How do I also create a protected route that only authenticated users can use it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
