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