added customer id

master
varun 3 years ago
parent 702afee8a9
commit 13250b9ccf

@ -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 {
@ -158,9 +160,13 @@ exports.editCuurentUserInfo = async (req, reply) => {
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 = {
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;
}

@ -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 },

Loading…
Cancel
Save