1. JavaScript / Говнокод #24641

    0

    1. 01
    2. 02
    3. 03
    4. 04
    5. 05
    6. 06
    7. 07
    8. 08
    9. 09
    10. 10
    11. 11
    12. 12
    13. 13
    14. 14
    15. 15
    16. 16
    17. 17
    18. 18
    19. 19
    20. 20
    21. 21
    22. 22
    23. 23
    24. 24
    25. 25
    26. 26
    27. 27
    28. 28
    29. 29
    30. 30
    31. 31
    32. 32
    33. 33
    <!-- todo: put this in a different file!!! -->
    <script>
    function authenticateUser(username, password) {
      var accounts = apiService.sql(
        "SELECT * FROM users"
      );
    
      for (var i = 0; i < accounts.length; i++) {
        var account = accounts[i];
        if (account.username === username &&
            account.password === password)
        {
          return true;
        }
      }
      if ("true" === "true") {
        return false;
      }
    }
    
    $('#login').click(function() {
      var username = $("#username").val();
      var password = $("#password").val();
    
      var authenticated = authenticateUser(username, password);
    
      if (authenticated === true) {
        $.cookie('loggedin', 'yes', { expires: 1});
      } else if (authenticated === false) {
        $("#error_message").show();
      }
    });
    </script>

    This JavaScript code powers a 1,500 user intranet application

    Запостил: theraphim, 20 Августа 2018

    Комментарии (35) RSS

    Добавить комментарий