Skip to content Skip to sidebar Skip to footer

Server Login Programme

so, I made my own little server. I tried to make it so, that you have to Login in order to access its files. I tried Javascript, but of course that is the worst thing to do (becaus

Solution 1:

You should do authentication and authorization on the server-side.

I assume, you have a webserver running. Behind this webserver you have an application-interface, where the requests to your webserver are put forth to your application. This is the "place" where you should do your auth-processing.

And whatever language you use to write your server-side application, I am sure there are already libraries that help you in that task. Proper authentication and authorization can be tricky, and there is no need to reinvent the wheel (unless of course there is a good reason to do so...).

Just google for "{your-language} authentication" or "{your-language} Framework authentication", where {your-language} is the programming language, you want to use on the server-side.

Anyhow, if you have no need for a full application, and just want to serve plain websites, you webserver should have a method for "Basic-Authentication". Again, just google for: "{your-webserver} Basic Authentication".

Solution 2:

Any login system needs to be serverside. Javascript is clientside. But there are many options depending on your server.

If you only have HTML and JS in your toolbox I'd look at using .htaccess if you are on a linux based server.

Solution 3:

You can use jQuery. Its very easy, but verification through javascript is very dangerous and easy to challenge. I recommend to use PHP

$(document).ready(function() {
  $("input[type='button']").click(function() {
    var user = $("input[type='text']").val();
    var pass = $("input[type='password']").val();

    if (user === "gast" && pass === "0000") {
      location.href = "gast.html";
    } else {
      alert("bad password!");
    }

  });
});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script><formname="login">
  Användar:
  <inputtype="text"name="user"value="gast"><br>Lösenord:
  <inputtype="password"name="pw"value=""><br><inputtype="button"value="Login"></form>

EXAMPLE1



when you must use javaScript, I recommend use Javascript Obfuscator: Javascript Obfuscator It's safer:

eval(function(p,a,c,k,e,d){e=function(c){return c};if(!''.replace(/^/,String)){while(c--){d[c]=k[c]||c}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(newRegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('$(12).13(4(){$("1[0=\'11\']").9(4(){6 7=$("1[0=\'14\']").3();6 5=$("1[0=\'2\']").3();18(7==="8"&&5==="20"){17.16="8.19"}15{21("10 2!")}})});',10,22,'type|input|password|val|function|pass|var|user|gast|click|bad|button|document|ready|text|else|href|location|if|html|0000|alert'.split('|'),0,{}))
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script><formname="login">
  Användar:
  <inputtype="text"name="user"value="gast"><br>Lösenord:
  <inputtype="password"name="pw"value=""><br><inputtype="button"value="Login"></form>

EXAMPLE2

Post a Comment for "Server Login Programme"