Просмотр исходного кода

Make all stored emails lowercase. Remove author from nonPosTransactions.

Lee Morgan 6 лет назад
Родитель
Сommit
45623c4eee
2 измененных файлов с 3 добавлено и 2 удалено
  1. 3 1
      controllers/home.js
  2. 0 1
      models/nonPosTransaction.js

+ 3 - 1
controllers/home.js

@@ -227,6 +227,7 @@ module.exports = {
 
     createMerchantClover: function(req, res){
         let data = JSON.parse(req.body.data);
+        data.email = data.email.toLowerCase();
 
         if(data.password.length < 15 || data.password !== data.confirmPassword){
             return res.render("error");
@@ -305,6 +306,7 @@ module.exports = {
 
     createMerchantNone: function(req, res){
         let data = JSON.parse(req.body.data);
+        data.email = data.email.toLowerCase();
 
         let salt = bcrypt.genSaltSync(10);
         let hash = bcrypt.hashSync(data.password, salt);
@@ -653,7 +655,7 @@ module.exports = {
     },
 
     login: function(req, res){
-        Merchant.findOne({email: req.body.email})
+        Merchant.findOne({email: req.body.email.toLowerCase()})
             .then((merchant)=>{
                 if(merchant){
                     bcrypt.compare(req.body.password, merchant.password, (err, result)=>{

+ 0 - 1
models/nonPosTransaction.js

@@ -5,7 +5,6 @@ let NonPosTransactionSchema = new mongoose.Schema({
         type: Date,
         required: [true, "Must provide a date and time"]
     },
-    author: String,
     merchant: {
         type: mongoose.Schema.Types.ObjectId,
         ref: "Merchant",