From 13250b9ccf4680334955955c8fcdd1dee84d93d8 Mon Sep 17 00:00:00 2001 From: varun Date: Mon, 6 Feb 2023 05:36:41 -0500 Subject: [PATCH] added customer id --- src/controllers/userController.js | 13 ++++++++++--- src/models/User.js | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/controllers/userController.js b/src/controllers/userController.js index ec70af04..df0c42e4 100644 --- a/src/controllers/userController.js +++ b/src/controllers/userController.js @@ -29,6 +29,8 @@ async function bcryptComparePassword(pwd, encpassword) { isSame = bcrypt.compare(pwd, encpassword); return isSame; } + + // Get current users exports.getCurrentUser = async (req, reply) => { try { @@ -157,10 +159,14 @@ exports.editCuurentUserInfo = async (req, reply) => { // Function accepts username, password , encrypts password and saves it in the database. exports.addUser = async (req, reply) => { try { - + + let i = 0 + var building= ((req.body.buildingName).slice(0, 3)).toUpperCase(); + var customer_id = `AWS${building}${i}` + console.log(customer_id) // console.log("This is the reply in the handler after the validations", reply); - userData = { - + userData = { + customerId: customer_id, username: req.body.username, emails: req.body.emails, password: req.body.password, @@ -201,6 +207,7 @@ exports.addUser = async (req, reply) => { user.passsword = usertobeInserted.password; user.buildingName = usertobeInserted.buildingName; user.inchargeName = usertobeInserted.inchargeName; + user.customerId = usertobeInserted.customer_id; } diff --git a/src/models/User.js b/src/models/User.js index 802a3d80..dd7508ea 100644 --- a/src/models/User.js +++ b/src/models/User.js @@ -15,6 +15,7 @@ const userSchema = new mongoose.Schema( username: { type: String, unique: true, trim: true }, phone: { type: String, unique: true, trim: true }, address: String, + customerId: String, buildingName: String, inchargeName: String, phoneVerified: { type: Boolean, default: false },