Browse Source

Merge branch 'master' into development

Lee Morgan 6 years ago
parent
commit
aaf519e2a3
3 changed files with 13 additions and 2 deletions
  1. 8 0
      app.js
  2. 3 1
      views/oldDashboardPage/account.js
  3. 2 1
      views/shared/validation.js

+ 8 - 0
app.js

@@ -8,6 +8,14 @@ mongoose.connect(process.env.SUBLINE_DB, {useNewUrlParser: true, useUnifiedTopol
 
 app.set("view engine", "ejs");
 
+function requireHTTPS(req, res, next) {
+    if (!req.secure && req.get('x-forwarded-proto') !== 'https' && process.env.NODE_ENV !== "development") {
+      return res.redirect('https://' + req.get('host') + req.url);
+    }
+    next();
+}
+
+app.use(requireHTTPS);
 app.use(session({
     secret: "Super Secret Subline Subliminally Saving Secrets So Sneaky Snakes Stay Sullen",
     cookie: {secure: false},

+ 3 - 1
views/oldDashboardPage/account.js

@@ -19,12 +19,14 @@ window.accountObj = {
             email: document.querySelector("#accountEmail").value
         }
 
-        if(validator.isSanitary(name)){
+        if(validator.isSanitary(data.name) && validator.isSanitary(data.email)){
             axios.post("/merchant/update", data)
                 .then((response)=>{
                     if(typeof(response.data) === "string"){
                         banner.createError(response.data);
                     }else{
+                        document.querySelector("#title").innerText = data.name;
+
                         merchant.name = data.name;
                         merchant.email = data.email;
 

+ 2 - 1
views/shared/validation.js

@@ -184,10 +184,11 @@ let validator = {
     },
 
     isSanitary: function(str){
-        let disallowed = ["\\", "<", ">", "$"];
+        let disallowed = ["\\", "<", ">", "$", "{", "}", "(", ")"];
 
         for(let char of disallowed){
             if(str.includes(char)){
+                banner.createError("Your string contains illegal characters");
                 return false;
             }
         }