Forráskód Böngészése

Bug fix: updating the password was not working.
Change all style for password resetting.

Lee Morgan 5 éve
szülő
commit
6be8e4bf90

+ 11 - 11
controllers/passwordReset.js

@@ -44,32 +44,32 @@ module.exports = {
     },
 
     resetPassword: function(req, res){
-        Merchant.findOne({_id: req.body.id})
-            .then((merchant)=>{
-                if(merchant.session.sessionId !== req.body.code){
-                    req.session.error = "YOUR ACCOUNT COULD NOT BE VERIFIED.  PLEASE CONTACT US IF THE PROBLEM PERSISTS.";
+        Owner.findOne({_id: req.body.id})
+            .then((owner)=>{
+                if(owner.session.sessionId !== req.body.code){
+                    req.session.error = "YOUR ACCOUNT COULD NOT BE VERIFIED. PLEASE CONTACT US IF THE PROBLEM PERSISTS.";
                     return res.redirect("/");
                 }
 
                 if(req.body.password !== req.body.confirmPassword){
                     req.session.error = "PASSWORDS DO NOT MATCH";
-                    return res.redirect(`/reset/${merchant._id}/${merchant.session.sessionId}`);
+                    return res.redirect(`/reset/${owner._id}/${owner.session.sessionId}`);
                 }
 
                 if(req.body.password.length < 10){
                     req.session.error = "PASSWORD MUST CONTAIN AT LEAST 10 CHARACTERS";
-                    return res.redirect(`/reset/${merchant._id}/${merchant.session.sessionId}`);
+                    return res.redirect(`/reset/${owner._id}/${owner.session.sessionId}`);
                 }
 
                 const salt = bcrypt.genSaltSync(10);
                 const hash = bcrypt.hashSync(req.body.password, salt);
 
-                merchant.password = hash;
+                owner.password = hash;
 
-                return merchant.save();
+                return owner.save();
             })
-            .then((merchant)=>{
-                if(merchant !== undefined){
+            .then((owner)=>{
+                if(owner !== undefined){
                     req.session.success = "PASSWORD SUCCESSFULLY UPDATED.  PLEASE LOG IN";
                     return res.redirect("/login");
                 }
@@ -80,7 +80,7 @@ module.exports = {
                 }else if(err.name === "ValidationError"){
                     req.session.error = err.errors[Object.keys(err.errors)[0]].properties.message;
                 }else{
-                    req.session.error = "ERROR: UNABLE TO UPDATE YOUR PASSWORD AT THIS TIME";
+                    req.session.error = "ERROR: UNABLE TO UPDATE YOUR PASSWORD";
                 }
                 return res.redirect("/");
             });

+ 10 - 23
views/passwordResetPages/email.ejs

@@ -1,37 +1,24 @@
 <!DOCTYPE html>
-<html>
+<html lang="en">
     <head>
         <meta charset="utf-8">
         <meta content="width=device-width, initial-scale=1" name="viewport"/>
         <title>The Subline</title>
         <link rel="icon" type="img/png" href="/shared/images/logo.png">
-        <link rel="stylesheet" href="/passwordResetPages/passwordReset.css">
-        <link href="https://fonts.googleapis.com/css?family=Saira&display=swap" rel="stylesheet"> 
+        <link rel="stylesheet" href="/passwordResetPages/style.css">
+        <link href="https://fonts.googleapis.com/css?family=Saira&display=swap" rel="stylesheet">
     </head>
     <body>
-        <div class="header">
-            <a class="headerStart" href="/" >
-                <img src="/shared/images/logo.png" alt="Subline">
-                <div class='headerLogo'>THE SUBLINE</div>
-            </a>
-        
-            <div class="headerEnd">
-                <a id="helpLink" class="headerHide" href="/help">HELP</a>
-        
-                <a id="privacyPolicyLink" class="headerHide" href="/privacy">PRIVACY POLICY</a>
-        
-                <a id="termsLink" class="headerHide" href="/terms">TERMS AND CONDITIONS</a>        
-            </div>
-        </div>
+        <form action="/reset/email" method="post">
+            <h1>Enter your email:</h1>
 
-        <h1 class="title">Enter your email to reset your password</h1>
+            <input name="email" type="email" placeholder="email">
 
-        <form class="form" action="/reset/email" method="post">
-            <input class="formInput" name="email" type="email" placeholder="email">
+            <input type="submit" value="SEND EMAIL">
 
-            <input class="button" type="submit" value="SEND EMAIL">
-        </form>
+            <a href="/login">CANCEL</a>
 
-        <p class="text">An email will be sent to you shortly with instructions on reseting your password.  If you don't recieve an email within one minute, then try again.</p>
+            <p>*An email will be sent to you shortly with instructions on reseting your password. If you don't recieve an email with one minute, then try again.</p>
+        </form>
     </body>
 </html>

+ 9 - 73
views/passwordResetPages/password.ejs

@@ -5,88 +5,24 @@
         <meta content="width=device-width, initial-scale=1" name="viewport"/>
         <title>The Subline</title>
         <link rel="icon" type="img/png" href="/shared/images/logo.png">
-        <link rel="stylesheet" href="/shared/shared.css">
-        <link rel="stylesheet" href="/passwordResetPages/passwordReset.css">
-        <link href="https://fonts.googleapis.com/css?family=Saira&display=swap" rel="stylesheet"> 
+        <link rel="stylesheet" href="/passwordResetPages/style.css">
+        <link href="https://fonts.googleapis.com/css?family=Saira&display=swap" rel="stylesheet">
     </head>
     <body>
-        <div class="header">
-            <a class="headerStart" href="/" >
-                <img src="/shared/images/logo.png" alt="Subline">
-                <div class='headerLogo'>THE SUBLINE</div>
-            </a>
-        
-            <div class="headerEnd">
-                <a id="helpLink" class="headerHide" href="/help">HELP</a>
-        
-                <a id="privacyPolicyLink" class="headerHide" href="/privacy">PRIVACY POLICY</a>
-        
-                <a id="termsLink" class="headerHide" href="/terms">TERMS AND CONDITIONS</a>        
-            </div>
-        </div>
+        <form action="/reset" method="post">
+            <h1>RESET PASSWORD:</h1>
 
-        <% include ../shared/banner.ejs %>
+            <input name="password" type="password" placeholder="NEW PASSWORD">
 
-        <h1 class="title">Reset Password</h1>
-
-        <form class="form" action="/reset" method="post">
-            <input name="password" type="password" class="formInput" placeholder="password">
-
-            <input name="confirmPassword" type="password" class="formInput" placeholder="confirm password">
+            <input name="confirmPassword" type="password" placeholder="CONFIRM PASSWORD">
 
             <input name="code" type="hidden" value="<%=code%>">
 
             <input name="id" type="hidden" value="<%=id%>">
 
-            <input class="button" type="submit" value="RESET PASSWORD">
-        </form>
-
-        <script>
-            let locals = <%- JSON.stringify(locals) %>
+            <input type="submit" value="RESET PASSWORD">
 
-            if(locals.banner !== undefined){
-                let bannerElem = document.getElementById("banner");
-                bannerElem.children[0].style.background = locals.banner.color;
-                bannerElem.children[1].innerText = locals.banner.message;
-                bannerElem.style.display = "flex";
-
-                switch(locals.banner.type){
-                    case "error":
-                        bannerElem.children[0].innerHTML = `
-                            <svg width="50" height="50" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
-                                <circle cx="12" cy="12" r="10"></circle>
-                                <line x1="15" y1="9" x2="9" y2="15"></line>
-                                <line x1="9" y1="9" x2="15" y2="15"></line>
-                            </svg>
-                        `;
-                        break;
-                    case "success":
-                        bannerElem.children[0].innerHTML = `
-                            <svg width="50" height="50" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
-                                <circle cx="12" cy="12" r="10"></circle>
-                                <line x1="12" y1="8" x2="12" y2="12"></line>
-                                <line x1="12" y1="16" x2="12.01" y2="16"></line>
-                            </svg>
-                        `;
-                        break;
-                    default: 
-                        bannerElem.children[0].innerHTML = `
-                            <svg width="50" height="50" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
-                                <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
-                                <polyline points="22 4 12 14.01 9 11.01"></polyline>
-                            </svg>
-                        `;
-                }
-
-                let timer = setTimeout(()=>{
-                    bannerElem.style.display = "none"
-                }, 7000);
-
-                bannerElem.children[2].onclick = ()=>{
-                    bannerElem.style.display = "none";
-                    clearTimeout(timer);
-                }
-            }
-        </script>
+            <a href="/login">CANCEL</a>
+        </form>
     </body>
 </html>

+ 92 - 0
views/passwordResetPages/password2.ejs

@@ -0,0 +1,92 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <meta content="width=device-width, initial-scale=1" name="viewport"/>
+        <title>The Subline</title>
+        <link rel="icon" type="img/png" href="/shared/images/logo.png">
+        <link rel="stylesheet" href="/shared/shared.css">
+        <link rel="stylesheet" href="/passwordResetPages/passwordReset.css">
+        <link href="https://fonts.googleapis.com/css?family=Saira&display=swap" rel="stylesheet"> 
+    </head>
+    <body>
+        <div class="header">
+            <a class="headerStart" href="/" >
+                <img src="/shared/images/logo.png" alt="Subline">
+                <div class='headerLogo'>THE SUBLINE</div>
+            </a>
+        
+            <div class="headerEnd">
+                <a id="helpLink" class="headerHide" href="/help">HELP</a>
+
+                <a id="privacyPolicyLink" class="headerHide" href="/privacy">PRIVACY POLICY</a>
+
+                <a id="termsLink" class="headerHide" href="/terms">TERMS AND CONDITIONS</a>
+            </div>
+        </div>
+
+        <% include ../shared/banner.ejs %>
+
+        <h1 class="title">Reset Password</h1>
+
+        <form class="form" action="/reset" method="post">
+            <input name="password" type="password" class="formInput" placeholder="password">
+
+            <input name="confirmPassword" type="password" class="formInput" placeholder="confirm password">
+
+            <input name="code" type="hidden" value="<%=code%>">
+
+            <input name="id" type="hidden" value="<%=id%>">
+
+            <input class="button" type="submit" value="RESET PASSWORD">
+        </form>
+
+        <script>
+            let locals = <%- JSON.stringify(locals) %>
+
+            if(locals.banner !== undefined){
+                let bannerElem = document.getElementById("banner");
+                bannerElem.children[0].style.background = locals.banner.color;
+                bannerElem.children[1].innerText = locals.banner.message;
+                bannerElem.style.display = "flex";
+
+                switch(locals.banner.type){
+                    case "error":
+                        bannerElem.children[0].innerHTML = `
+                            <svg width="50" height="50" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+                                <circle cx="12" cy="12" r="10"></circle>
+                                <line x1="15" y1="9" x2="9" y2="15"></line>
+                                <line x1="9" y1="9" x2="15" y2="15"></line>
+                            </svg>
+                        `;
+                        break;
+                    case "success":
+                        bannerElem.children[0].innerHTML = `
+                            <svg width="50" height="50" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+                                <circle cx="12" cy="12" r="10"></circle>
+                                <line x1="12" y1="8" x2="12" y2="12"></line>
+                                <line x1="12" y1="16" x2="12.01" y2="16"></line>
+                            </svg>
+                        `;
+                        break;
+                    default: 
+                        bannerElem.children[0].innerHTML = `
+                            <svg width="50" height="50" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
+                                <path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
+                                <polyline points="22 4 12 14.01 9 11.01"></polyline>
+                            </svg>
+                        `;
+                }
+
+                let timer = setTimeout(()=>{
+                    bannerElem.style.display = "none"
+                }, 7000);
+
+                bannerElem.children[2].onclick = ()=>{
+                    bannerElem.style.display = "none";
+                    clearTimeout(timer);
+                }
+            }
+        </script>
+    </body>
+</html>

+ 73 - 0
views/passwordResetPages/style.css

@@ -0,0 +1,73 @@
+*{margin:0;padding:0;font-family:'Saira',sans-serif;}
+
+body{
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    height: 100vh;
+    background: rgb(201, 201, 201);
+}
+
+form{
+    display: flex;
+    flex-direction: column;
+    border: 1px solid black;
+    padding: 25px;
+    background: white;
+    max-width: 500px;
+}
+
+    form > *{
+        margin: 15px;
+    }
+
+    form p{
+        font-size: 12px;
+        color: rgb(85, 85, 85);
+    }
+
+input[type=submit]{
+    background: rgb(0, 27, 45);
+    border: none;
+    text-decoration: none;
+    padding: 10px 25px;
+    color: white;
+    cursor: pointer;
+    text-align: center;
+    font-size: 15px;
+    min-width: 100px;
+    margin: 5px;
+    max-height: 52px;
+}
+
+    input[type=submit]:hover{
+        background: rgb(179, 191, 209);
+        color:black;
+    }
+
+    input[type=submit]:active{
+        background: rgb(240, 252, 255);
+    }
+
+    a{
+        display: initial;
+        background: rgb(255, 99, 107);
+        border: none;
+        text-decoration: none;
+        padding: 10px 25px;
+        color: black;
+        cursor: pointer;
+        text-align: center;
+        font-size: 15px;
+        min-width: 100px;
+        margin: 5px;
+        max-height: 52px;
+    }
+    
+        a:hover{
+            background: rgb(255, 129, 137);
+        }
+    
+        a:active{
+            background: rgb(240, 252, 255);
+        }