diff --git a/abhinavs-blog/blog-functionality.js b/abhinavs-blog/blog-functionality.js index 4ba3c3c..396f990 100644 --- a/abhinavs-blog/blog-functionality.js +++ b/abhinavs-blog/blog-functionality.js @@ -1,15 +1,18 @@ //for first time using the database:- -credentialArray = { - "default": "default_pass125" -}; -localStorage.setItem('credentials', JSON.stringify(credentialArray)); -credentialArray = localStorage.getItem('credentials') +// credentialArray = { +// "default": "default_pass125" +// }; +// localStorage.setItem('credentials', JSON.stringify(credentialArray)); +// let credentialArray = JSON.parse(localStorage.getItem('credentials')); + +let credentialArray = JSON.parse(localStorage.getItem('credentials')) || {}; function createUser(userID, pass){ if(credentialArray[userID]){ console.log("User already exists"); } else{ + //checks the strength of the password if(checkStrenth(pass)){ credentialArray[userID] = pass; console.log("User created successfully"); @@ -46,7 +49,7 @@ function checkStrenth(pass){ } } if(hasInt && hasSpclChr && !hasPattern){ - console.log("Has a special character and a number."); + // console.log("Has a special character and a number."); return true; } // FOR DEBUG: @@ -63,3 +66,28 @@ function checkStrenth(pass){ } createUser("Abhinav", "my_passAbhinav123"); +createUser("Abhinav", "sdfds@#Ainav123"); + + + + +//Able to click edit button after entering the correct credentials +//and after that a div apears showing the input fields to fill out the necesarry +//parameters of a blog post. + +const editButton = document.getElementById('myButton'); +//sign in or edit +function editValidate(){ + const username = document.querySelector(".username-field").value; + const password = document.querySelector(".password-field").value; + + if(credentialArray[username] == password){ + alert("logged in"); + window.location = "login-accepted.html"; + } + else{ + alert("wrong username or password"); + } + document.querySelector(".password-field").value = ""; +} +button.addEventListener('click', editValidate); \ No newline at end of file diff --git a/abhinavs-blog/blog.html b/abhinavs-blog/blog.html index 17c80c2..5e6c3bd 100644 --- a/abhinavs-blog/blog.html +++ b/abhinavs-blog/blog.html @@ -25,5 +25,23 @@ + + + + \ No newline at end of file diff --git a/abhinavs-blog/login-style.css b/abhinavs-blog/login-style.css new file mode 100644 index 0000000..6616ac0 --- /dev/null +++ b/abhinavs-blog/login-style.css @@ -0,0 +1,74 @@ +.login-text{ + font-family: monospace; + font-size: 30px; + font-weight: 600; + text-align: center; + margin-bottom: 50px; +} + + +.center-container { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + /* height: 100vh; //Adjust the height as needed */ +} + +.inputs { +padding: 10px; +width: 200px; +border-radius: 20px; +border-width: 2px; +margin-bottom: 15px; +font-family: monospace; +font-size: 15px; +} + +.login-button-css{ + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; +} +.login-button{ + font-family: monospace; + font-size: 14px; + border: none; + background-color:rgb(243, 243, 243); + border-radius: 20px; + padding-left: 20px; + padding-right: 20px; + padding-top:10px; + padding-bottom: 10px; +} + +.login-button:hover{ + background-color: rgb(230, 230, 230); + cursor:pointer; +} + +.signup-button{ + font-family: monospace; + font-size: 14px; + border: none; + background-color:rgb(243, 243, 243); + border-radius: 20px; + padding-left: 20px; + padding-right: 20px; + padding-top:10px; + padding-bottom: 10px; +} + +.signup-button:hover{ + background-color: rgb(230, 230, 230); + cursor:pointer; +} + +.login-box { + background-color: #f9f9f9; /* Change to your desired color */ + /* border: 1px solid #ccc; Change to your desired border */ + padding: 20px; /* Adjust as needed */ + margin: 30px; /* Adjust as needed */ + border-radius: 50px; /* Optional: to make the corners rounded */ +} \ No newline at end of file