how can i make the tab close upon user opening inspect element? or can i store passwords somewhere that users cant access?

Viewed 16

So I am making a website with logins that you need to contact me to obtain (to avoid spam bots and stuff) however I do not know how to hide the passwords, here is a code of all JavaScript I use for the site:

  //specials
  const enabledUsers = ['adminAccount', 'POGDUCKIE']
  const unc = "adminAccount"
  const pwc = "TEST"
  const unc2 = "POGDUCKIE"
  const pwc2 = "TEST"
  const unc3 = "fierytech"
  const pwc3 = "TEST"
  const member = ['POGDUCKIE']
  const partner = ['none yet']
  const admin = ['adminAccount']
  const owner = ['fierytech']

  
  var user = document.getElementById("user")
        function redirectAddAurasouls(){
            document.write("Here is the bot invite link: <a href=https://discord.com/api/oauth2/authorize?client_id=944639749195448320&permissions=8&scope=bot>https://discord.com/api/oauth2/authorize?client_id=944639749195448320&permissions=8&scope=bot</a>. Thank you for adding aurasouls!<br><br><button onclick=location.reload()>Go Back</button>")
        }
        
        function redirectDiscordInvite(){
                document.write("The Discord Support Server Invite Link Is: <a target=blank_ href=https://discord.gg/khR9DFNqs6>https://discord.gg/khR9DFNqs6</a><br><button onclick=location.reload()>Go Back</button>");
            }
  
  function redirectStaff(){
            document.getElementById("passwordTable").style.display = "none";
        } 

  
  function passwordCheck(){ 
            var pw = document.getElementById("Password").value;
    var un = document.getElementById("Username").value;
                if(un == unc) {  
          if(pw == pwc){
                      redirectStaff()
            user.innerHTML = "adminAccount"
          }
          else{
            document.getElementById("passwordStatus").innerHTML = "Incorrect Password. Please try again.";
          }
                }
                else{
                    if(un == unc2) {  
          if(pw == pwc2){
                      redirectStaff()
            user.innerHTML = "POGDUCKIE"
          }
          else{
            document.getElementById("passwordStatus").innerHTML = "Incorrect Password. Please try again.";
          }
                }
                else{
                    document.getElementById("passwordStatus").innerHTML = "Incorrect Username. Please contact FieryTech on discord to get a free login.";
                } 
            }
                } 
  //the code below stops user from opening console
document.onkeydown = function(e) {
  if(event.keyCode == 123) {
     return false;
  }
  if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)) {
     return false;
  }
  if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)) {
     return false;
  }
  if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)) {
     return false;
  }
  if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) {
     return false;
  }
}

As you can see, the JS file has something to prevent users opening console with keybinds, but the user can still access inspect element in other ways. Is there a way I can externally store the data so only the javascript code can access it so users can't steal logins? If there is any way possible to hide these logins please let me know.

Thanks

P.S. before you say that some of the JS doesn't work, I stopped working on the login until I find a way to properly store logins.

1 Answers

The only marginally secure way to store passwords in code that runs on the client is to hash them yourself first, send the hashes, and then to perform hashing on the user passwords when they're submitted. Possible, but convoluted and still not all that secure.

The only good way to do something like you're trying to do is to store the passwords on the server only. Don't ever send the data to the client. Any data sent to the client can be easily read and reverse-engineered by the client.

When the user submits a password, make a request to your server with the password. On the server, hash the password that the client sent, and then look up in your database of users whether the username and password hash match. If so, let them in (with all the appropriate privileges) - if not, tell them that their credentials were incorrect.

Related