Libraryless. Click here for Pure Java version (5722L/37K/124K).
!7 static new L<S> authorizedDialogIDs; p { load("authorizedDialogIDs"); } static S html(S subUri, Map<S, S> params) { S anonID = cast get(getMainBot(), "anonymousDialogID"); S dialogID = getDialogID(); if (empty(dialogID) || eq(dialogID, anonID)) ret "No cookie - cannot authenticate! (dialog ID: " + dialogID + ")"; boolean in = authorizedDialogIDs.contains(dialogID); if (in) ret "You're in! " /* + ahref("Log out") */; S realPW = realPW(); if (empty(realPW)) ret "No password set by admin - please put password in: " + realPWFile().getAbsolutePath(); S pw = params.get("pw"); if (nempty(pw)) { if (neq(pw, realPW)) { print("XXX - Alert, bad PW entered on web - XXX"); ret "Bad PW, bugger"; } else { authorizedDialogIDs.add(dialogID); save("authorizedDialogIDs"); ret "OK, you're in! Dialog ID: " + dialogID; } } else { S formContents = tag("p", "Enter deh pass word: " + htag("input", "", "type", "password", "name", "pw", "value", params.get("pw"))); formContents += tag("input", "", "type", "submit", "value", "Submit!"); ret tag("form", formContents, "method", "POST"); } } static File realPWFile() { ret secretProgramFile("master-pw"); } static S realPW() { ret trim(loadTextFile(realPWFile())); } static boolean currentHttpRequestAuthorized() { ret authorizedDialogIDs.contains(getDialogID()); }
download show line numbers debug dex old transpilations
Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xfbsdwenvhih
No comments. add comment
Snippet ID: | #1002590 |
Snippet name: | Web Auth Bot (LIVE) |
Eternal ID of this version: | #1002590/3 |
Text MD5: | 2208497a37730c4d907412920aa92e39 |
Transpilation MD5: | e7c5315e3571b416d7f3c298dcacba28 |
Author: | stefan |
Category: | eleu |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2019-04-09 12:02:02 |
Source code size: | 1466 bytes / 50 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 805 / 9336 |
Version history: | 2 change(s) |
Referenced in: | [show references] |