diff --git a/app.js b/app.js index 283c7ba..5b7a7bb 100644 --- a/app.js +++ b/app.js @@ -2,6 +2,7 @@ let express = require("express"); let morgan = require("morgan"); let indexRoute = require("./routes/index"); +let checkMail = require("./routes/checkMail"); let notFoundRoute = require("./routes/notFound"); let errorRoute = require("./routes/error"); @@ -12,6 +13,7 @@ app.use(morgan("dev")) .use(express.static("public")) .set("view engine", "pug") .use("/", indexRoute) + .use("/checkmail", checkMail) .use(notFoundRoute) .use(errorRoute) .listen(process.env.PORT || 8080); diff --git a/public/css/main.css b/public/css/main.css index 69dd262..63562ee 100644 --- a/public/css/main.css +++ b/public/css/main.css @@ -13,27 +13,12 @@ body{ body { background: linear-gradient(-45deg, #ee7752, #23a6d5); - background-size: 200% 200%; - animation: gradient 15s ease infinite; + background-size: 100%; } -@keyframes gradient { - 0% { - background-position: 0% 50%; - } - 50% { - background-position: 100% 50%; - } - 100% { - background-position: 0% 50%; - } -} - - .container{ width: 100%; height: 100vh; - border-bottom: 0.2vw solid black; } #main h1{ @@ -176,10 +161,15 @@ input:focus{ } .hide{ - + display : none; } h2#cookie_text{ text-align: center; font-size: 2.5vw; -} \ No newline at end of file +} + +#result_mail a { + color: #001bff; + cursor: pointer; +} diff --git a/public/js/main.js b/public/js/main.js index 8387661..64c6e6e 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -10,36 +10,70 @@ const cookie = document.querySelector("#cookie"); mailRegex = new RegExp("(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\\])"); -document.querySelectorAll("input").forEach((el) => { - el.addEventListener("change", (e => { +document.querySelectorAll("input").forEach(el => { + el.addEventListener("change", (() => { el.classList.remove("error"); })); }); -main.querySelector("input").addEventListener("keyup", (e) => { - if (e.key === "Enter") { - mailValid(); - } +resultMail.querySelector("a").addEventListener("click", () => { + passwordTest.classList.remove("hide"); + passwordTest.scrollIntoView({"behavior": "smooth"}); }); +main.querySelector("#email").addEventListener("keyup", e => { + if (e.key === "Enter") + mailValid(); +}); + +passwordTest.querySelector("#password").addEventListener("keyup", e => { + if (e.key === "Enter") + passwordCheck(); +}) + function mailValid() { - let input = main.querySelector("input"); + let input = main.querySelector("#email"); if (mailRegex.test(input.value)) { resultMail.classList.remove("hide"); - resultMail.scrollIntoView({ - "behavior": "smooth" - }); + resultMail.scrollIntoView({"behavior": "smooth"}); } else { input.classList.add("error"); } } -function mailCheck(mail) { - let Http = new XMLHttpRequest(); - Http.open("GET", "https://cors-anywhere.herokuapp.com/https://haveibeenpwned.com/unifiedsearch/" + mail); - //Http.setRequestHeader("Origin", "haveibeenpwned.com") - Http.send(); - Http.response; +function passwordCheck() { + let pass = passwordTest.querySelector("#password").value; + let secLevel = { + "length": false, + "uppercase": false, + "lowercase": false, + "number": false, + "special": false, + "identical": false, + "name": false, + "commonly": false + } + if (pass.length >= 8) + secLevel.length = true + if (pass.match("[A-Z]")) + secLevel.uppercase = true + if (pass.match("[a-z]")) + secLevel.lowercase = true + if (pass.match("[0-9]")) + secLevel.number = true + if (pass.match("\W")) + secLevel.special = true + if (pass.match) + secLevel.identical = true + if (pass.match) + secLevel.name= true + if (["123456", "password", "123456789", "12345678", "12345", "111111", "1234567", "sunshine", "qwerty", "iloveyou", "princess", "admin", "welcome", "666666", "abc123", "football", "123123", "monkey", "654321", "!@#$%^&*", "charlie", "aa123456", "donald", "password1", "qwerty123"].indexOf(pass) <= -1) + secLevel.commonly = true + resultPassword.classList.remove("hide"); + resultPassword.scrollIntoView({"behavior": "smooth"}); } +function mailCheck(mail) { + +} diff --git a/routes/checkMail.js b/routes/checkMail.js new file mode 100644 index 0000000..a0a2798 --- /dev/null +++ b/routes/checkMail.js @@ -0,0 +1,10 @@ +let router = require("express").Router(); +let https = require('https') + + +router.get("/", (req, res) => { + +}); + + +module.exports = router; diff --git a/views/index.pug b/views/index.pug index 4d01f38..89759a4 100644 --- a/views/index.pug +++ b/views/index.pug @@ -4,21 +4,29 @@ block content div.triangle-right h1 Do you really think you're safe on the web ? label(for="email") Let's begin by check if your email is safe ;) - input(type="email" id="email" name="email" placeholder="example : xyz@gmail.com") + input#email(type="email" name="email" placeholder="example : xyz@gmail.com") div.trapezoid div.container.hide#result_mail h1 Results h2 h2 Let's see what about your - a(href="#password_test") passwords ? + a passwords ? div.container.hide#password_test h1 Do you really think your passwords are safe ? label(for="password") Let's see if your password is secure - input(type="password" id="password" name="password" placeholder="your password: MDPdrive2") + input#password(type="password" name="password" placeholder="your password: MDPdrive2") div.container.hide#result_password h1 Results h2 ul + li MUST contain at least 8 characters (12+ recommended) + li MUST contain at least one uppercase letter + li MUST contain at least one lowercase letter + li MUST contain at least one number + li MUST contain at least one special character (!”#$%&'()*+,-./:;<=>?@[\]^_`{|}~ ) + li MAY NOT contain more than two identical characters in a row + li MAY NOT contain first name, last name, email address mailbox or domain, company name or commonly used passwords + li MAY NOT match commonly used password character patterns div.container.hide#password_manage h1 To make your life easier, use a password manager ! h2