Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function controller()
- {
- drawLoginPage();
- document.getElementById("enter").onclick = function()
- {
- const USER = document.getElementById("username").value;
- const PASSWORD = document.getElementById("password").value;
- if (USER == '' || PASSWORD == '')
- alert("Wrong login or password");
- else {
- window.localStorage.removeItem('userIsFind');
- findTheUser(USER, PASSWORD);
- let FindUser = localStorage['userIsFind'] || "false";
- if (FindUser == "true")
- {
- document.getElementById("loginFormId").remove();
- createStorePageForUser(Log);
- }
- else alert("Wrong login or password");
- }
- }
- }
- function findTheUser(Log, Pas)
- {
- fetch("Users.json")
- .then(function(response)
- {
- return response.json();
- })
- .then(function(data)
- {
- let currentUser = 0;
- while ( currentUser < data.length && (data[currentUser].username != Log && data[currentUser].password != Pas )) currentUser++;
- localStorage['userIsFind'] = String(currentUser != data.length);
- });
- }
Add Comment
Please, Sign In to add comment