diff --git a/.vscode/settings.json b/.vscode/settings.json index 28a51d5..a1c4910 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,3 @@ { - "compile-hero.disable-compile-files-on-did-save-code": false + "compile-hero.disable-compile-files-on-did-save-code": true } \ No newline at end of file diff --git a/content/js/config/index.js b/content/js/config/index.js index 1b6bfc5..1b41c82 100644 --- a/content/js/config/index.js +++ b/content/js/config/index.js @@ -41,7 +41,7 @@ const locations = { "desc": "The minimal page", "aliases": [ "mini","minimal", - "txt" + "txt", "min" ] }, diff --git a/content/js/generic/index.js b/content/js/generic/index.js index 4a1c6f1..f2419f8 100644 --- a/content/js/generic/index.js +++ b/content/js/generic/index.js @@ -1,4 +1,5 @@ var root = false; +var not_return = false; add_boot_entry(boot_message) @@ -33,15 +34,31 @@ async function main() { 6: { "type": 'ok', "text": `'${site_name}' has been booted! Type help for help.` + }, + 7: { + "type": 'error', + "text": 'A fatal error has occured, report it here', + "sleep_time": 0 } } if (!is_logged_in) { - await add_boot_entry({0: tmp_boot_entries[0], 1: tmp_boot_entries[1]}); + await add_boot_entry({ 0: tmp_boot_entries[0], 1: tmp_boot_entries[1] }); await sleep(500); - user_account_create(); + await user_account_create() + .catch(async (e) => { + window.localStorage.clear(); + let boot_error = { + "type": 'error', + "text": e, + "sleep_time": 0 + }; - return 1; + await add_boot_entry({ 0: boot_error, 1: tmp_boot_entries[7] }); + not_return = true; + }); + + if (!not_return) window.location.reload(); } else { await add_boot_entry({ 0: tmp_boot_entries[3] diff --git a/content/js/handlers/user_account.js b/content/js/handlers/user_account.js index c68dc8f..b78d469 100644 --- a/content/js/handlers/user_account.js +++ b/content/js/handlers/user_account.js @@ -20,14 +20,13 @@ async function user_account_create() { ) if (!valid) { - if (confirm('The credentials you entered are not valid, try again?')) { + if (confirm('The credentials you entered are not valid (password/username too short or the password don\'t match), try again?')) { user_account_create(); return 1; } add_boot_entry({0: tmp_boot_entries[0]}); await sleep(2500); - window.location.reload(); } else { alert('The next popup will show your credentials, press OK to proceed') let confirm_credentials = confirm(`Are these credentials correct?: @@ -37,9 +36,8 @@ async function user_account_create() { if (confirm_credentials) { localStorage.setItem('username', username) localStorage.setItem('password', hash(password)) - + alert('Credentials saved!') - window.location.reload(); } } } diff --git a/content/js/shell/commands.js b/content/js/shell/commands.js index e9b7e8e..ef7376c 100644 --- a/content/js/shell/commands.js +++ b/content/js/shell/commands.js @@ -98,4 +98,16 @@ var commands = { ] } }, + + "whoami": { + "func": whoami, + "root_only": false, + "help": { + "desc": "A command to show your current user", + "short_desc": "Show user", + "examples": [ + "whoami" + ] + } + }, } diff --git a/content/js/shell/func.js b/content/js/shell/func.js index 73d6682..58d271e 100644 --- a/content/js/shell/func.js +++ b/content/js/shell/func.js @@ -143,3 +143,8 @@ function passwd() { return 'Wrong password' } } + + +function whoami() { + return root ? "root" : window.localStorage.getItem("username"); +} diff --git a/index.html b/index.html index 41bad40..d78d132 100644 --- a/index.html +++ b/index.html @@ -28,8 +28,9 @@