-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathauth.js
More file actions
30 lines (22 loc) · 714 Bytes
/
auth.js
File metadata and controls
30 lines (22 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const User = require("../models/users.model");
module.exports={
checkusername:async function(req,res,next){
const username=req.body.username;
const user= await User.findOne({username:username});
if(user != null)
{
return res.status(422).json({Status:false,errorName:"username"})
}
next();
},
checkemail:async function(req,res,next)
{
const email=req.body.email;
const checkEmail=await User.findOne({email:email});
if(checkEmail != null)
{
return res.status(422).json({Status:false,errorName:"email"})
}
next();
}
}