function login() {
  var validUserInt = 0;
  for(var i = 0; i < userArr.length; i++){
      //This prevents "case sensitive" usernames from being mis-interpreted
    if(userArr[i].userName.toLowerCase() == username.value.toLowerCase()){
        try {
            if(decode(userArr[i].encodeStr) == pin.value){
                loginBool = true;
                validUserInt = i;
                break;
            } else {

            }
        } catch (err) {
            if(userArr[i].pin == pin.value){
                loginBool = true;
                validUserInt = i;
                break;
            } else {

            }
        }
    }
  }
  if (loginBool === true){
    document.getElementById("loginInfo").innerHTML = "User " + userArr[validUserInt].userName + " Authenticated";
    validUser = userArr[validUserInt];
    sessionStorage.setItem("validUser", JSON.stringify(validUser));
    sessionStorage.setItem("userArr", JSON.stringify(userArr));
    window.location.href = "home.html";
  } else if (loginBool === false) {
    document.getElementById("loginInfo").innerHTML = "Username or Password Incorrect";
    updateMaintenanceLog("index", "Invalid Login: " + username.value.toLowerCase() + " " + pin.value.toString());
  }
}
//user will be told "User (USER NAME) Authenticated" or "Username or Password Incorrect".
user will be told "User (USER NAME) Authenticated" or "Username or Password Incorrect".
user will be told " User ( USER NAME ) Authenticated " or " Username or Password Incorrect " .
function login() {
  var validUserInt = 0;
  for(var i = 0; i < userArr.length; i++){
    if(userArr[i].userName.toLowerCase() == username.value.toLowerCase()){
        try {
            if(decode(userArr[i].encodeStr) == pin.value){
                loginBool = true;
                validUserInt = i;
                break;
            } else {
            }
        } catch (err) {
            if(userArr[i].pin == pin.value){
                loginBool = true;
                validUserInt = i;
                break;
            } else {
            }
        }
    }
  }
  if (loginBool === true){
    document.getElementById("loginInfo").innerHTML = "User " + userArr[validUserInt].userName + " Authenticated";
    validUser = userArr[validUserInt];
    sessionStorage.setItem("validUser", JSON.stringify(validUser));
    sessionStorage.setItem("userArr", JSON.stringify(userArr));
    window.location.href = "home.html";
  } else if (loginBool === false) {
    document.getElementById("loginInfo").innerHTML = "Username or Password Incorrect";
    updateMaintenanceLog("index", "Invalid Login: " + username.value.toLowerCase() + " " + pin.value.toString());
  }
}
function login ( ) { var validUserInt = 0 ; for ( var i = 0 ; i < userArr . length ; i ++ ) { if ( userArr [ i ] . userName . toLowerCase ( ) == username . value . toLowerCase ( ) ) { try { if ( decode ( userArr [ i ] . encodeStr ) == pin . value ) { loginBool = true ; validUserInt = i ; break ; } else { } } catch ( err ) { if ( userArr [ i ] . pin == pin . value ) { loginBool = true ; validUserInt = i ; break ; } else { } } } } if ( loginBool === true ) { document . getElementById ( "loginInfo" ) . innerHTML = "User " + userArr [ validUserInt ] . userName + " Authenticated" ; validUser = userArr [ validUserInt ] ; sessionStorage . setItem ( "validUser" , JSON . stringify ( validUser ) ) ; sessionStorage . setItem ( "userArr" , JSON . stringify ( userArr ) ) ; window . location . href = "home.html" ; } else if ( loginBool === false ) { document . getElementById ( "loginInfo" ) . innerHTML = "Username or Password Incorrect" ; updateMaintenanceLog ( "index" , "Invalid Login: " + username . value . toLowerCase ( ) + " " + pin . value . toString ( ) ) ; } }
user will be told "User (USER NAME) Authenticated" or "Username or Password Incorrect".
user will be told " User ( USER NAME ) Authenticated " or " Username or Password Incorrect " .
//This prevents "case sensitive" usernames from being mis-interpreted