Obviously Broken Login Code
<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) $.cookie("loggedin", 'yes', { expires: 1 }); } else if (authenticated === false) $("#error_message").show(LogIn Failed) }); </script>
A screenshot shows deliberately broken JavaScript login code. The function checks the database, but then always evaluates "true" === "true" and returns false, while the later conditional also has mismatched braces, making the authentication logic absurdly unreliable. It is used as a reaction to joke about insecure, buggy, or amateur programming. EN: A screenshot shows deliberately broken JavaScript login code. The function checks the database, but then always evaluates "true" === "true" and returns false, while the later conditional also has mismatched braces, making the authentication logic absurdly unreliable. It is used as a reaction to joke about insecure, buggy, or amateur programming.
code screenshot / скриншот кодаJavaScript code / код JavaScriptlogin form / форма входаusername field / поле имени пользователяpassword field / поле пароляdatabase query / запрос к базе данныхcomputer screen / экран компьютераblack background / чёрный фонsyntax highlighting / подсветка синтаксисаerror message / сообщение об ошибке
- @gentoomemes / 14487 2024-11-04
- Type
- image
- Size
- 369×800 · 31.5 KiB
- Mood
- absurd, sarcastic
- Language
- en
- Added