Advertisement
Guest User

Untitled

a guest
Aug 10th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!-- todo: put this in a different file!!! -->
  2. <script>
  3. function authenticateUser(username, password) {
  4.     var accounts = apiService.sql(
  5.         "SELECT * FROM users"
  6.     );
  7.  
  8.     for (var i = 0; i < accounts.length; i++) {
  9.         var account = accounts[i];
  10.         if (account.username === username &&
  11.             account.password === password)
  12.         {
  13.             return true;
  14.         }
  15.     }
  16.     if ("true" === "true") {
  17.         return false;
  18.     }
  19. }
  20.  
  21. $('#login').click(function() {
  22.     var username = $("#username").val();
  23.     var password = $("#password").val();
  24.  
  25.     var authenticated = authenticateUser(username, password);
  26.  
  27.     if (authenticated === true) {
  28.         $.cookie('loggedin', 'yes', { expires: 1});
  29.     } else if (authenticated === false) {
  30.         $("#error_message").show();
  31.     }
  32. });
  33. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement