Skip to content

Commit 55fd552

Browse files
committed
last chances
1 parent f739ae6 commit 55fd552

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

src/middlewares/auth.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ const userAuth = async (req,res,next) => {
1313
if(!token){
1414
return res.status(401).send("Unauthorized: Please Login First");
1515
}
16+
// console.log("Token received:", token);
17+
// console.log("JWT_SECRET:", JWT_SECRET);
1618
const decodedObj = await jwt.verify(token, JWT_SECRET);
1719
const {_id} = decodedObj;
1820
const user = await User.findById(_id);

src/models/user.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ const userSchema = new Schema({
3636
}
3737
},
3838
phoneNo:{
39-
type: String,
40-
required: true,
41-
unique: true,
39+
type: String,
4240
minLength: 10,
4341
maxLength: 10,
4442
validate(value){

src/routes/auth.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const {validateSignupData} = require("../utils/validation");
66
const authRouter = express.Router();
77

88
authRouter.post("/signup", async (req, res) => {
9-
const {firstName,lastName,emailId,phoneNo,password,age,gender,about,hobbies} = req.body;
9+
const {firstName,lastName,emailId,password} = req.body;
1010
// first we have to validate the userData
1111
try {
1212
validateSignupData(req);
@@ -15,7 +15,6 @@ authRouter.post("/signup", async (req, res) => {
1515
firstName,
1616
lastName,
1717
email: emailId,
18-
phoneNo,
1918
password: hashedPassword
2019
});
2120
const savedUser = await user.save();

src/utils/validation.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,11 @@ const validateNewPassword = (req) => {
1818
}
1919
};
2020
const validateSignupData = (req) =>{
21-
const {firstName,lastName,emailId,phoneNo,password} = req.body;
21+
const {firstName,lastName,emailId,password} = req.body;
2222

23-
if(!firstName || !lastName || !emailId || !phoneNo || !password){
23+
if(!firstName || !lastName || !emailId || !password){
2424
throw new Error("Please fill all the fields");
2525
}
26-
else if(!validator.isMobilePhone(phoneNo)){
27-
throw new Error("Phone number is not valid");
28-
}
2926
else if(!validator.isEmail(emailId)){
3027
throw new Error("Email address is not valid");
3128
}

0 commit comments

Comments
 (0)