1

I am doing a logging system with a function that verifies the data of an array, but I would like that after that once the correct data is entered it takes you to another page. Here is the first part of my script.

var objUsers = [
  {
    username: "vocal",
    password: "xp20yz"
  },
  {
    username: "admin",
    password: "portilla"
  }
]
function getLogin() {
  var username = document.getElementById("username").value
  var password = document.getElementById("password").value
  
  for(i = 0; i < objUsers.length; i++){
    if(username == objUsers[i].username && password == objUsers[i].password)
  {
    console.log(username + " Estás dentro ")
    return
  }
  console.log("Datos incorrectos")
}
}

Please help me!

  • Hi, thanks for choosing stackoverflow. Let's get back to us What technology do you use? Which framework? – Κωλζαρ Aug 02 '21 at 16:54
  • 2
    You are probably aware of that, but this is very insecure because everybody will be able to read the correct credentials in the javascript code! You can nevertheless redirect by setting `window.location.replace("https://example.com")` as described here https://stackoverflow.com/questions/503093/how-do-i-redirect-to-another-webpage – Florian Bauer Aug 02 '21 at 16:56
  • if you use react, this is a basic setup [React login](https://medium.com/technoetics/create-basic-login-forms-using-react-js-hooks-and-bootstrap-2ae36c15e551) – Mike Aug 02 '21 at 17:23

0 Answers0