From 05ccffc79f85a8bec8a72d36b79cf3b5c07ca66e Mon Sep 17 00:00:00 2001 From: NaysKutzu Date: Mon, 9 Dec 2024 00:21:44 +0100 Subject: [PATCH] PUSH -> Better file structure -> Account token resets on password change! -> Fix the real user role is not really real user! -> Telemetry --- backend/app/Api/User/Auth/ResetPassword.php | 3 +- backend/app/Api/User/Session.php | 2 +- backend/app/Chat/User.php | 2 +- backend/app/MythicalSystems/Telemetry.php | 48 + .../MythicalSystems/TelemetryCollection.php | 10 + backend/mythicalclient | 4 + backend/public/index.php | 4 + frontend/package.json | 4 +- .../src/components/admin/LayoutDashboard.vue | 343 +++++++ .../components/{ => client}/Auth/FormCard.vue | 0 .../{ => client}/Auth/FormInput.vue | 0 .../Dashboard/Account/Activities.vue | 2 +- .../Dashboard/Account/ApiKeys.vue | 2 +- .../Dashboard/Account/Billing.vue | 4 +- .../{ => client}/Dashboard/Account/Layout.vue | 0 .../{ => client}/Dashboard/Account/Mails.vue | 4 +- .../Dashboard/Account/Security.vue | 2 +- .../Dashboard/Account/Settings.vue | 4 +- .../Dashboard/Admin/Settings/Advanced.vue | 2 +- .../Dashboard/Admin/Settings/CloudFlare.vue | 6 +- .../Dashboard/Admin/Settings/Dashboard.vue | 6 +- .../Dashboard/Admin/Settings/Email.vue | 6 +- .../{ => client}/Errors/ErrorPage.vue | 0 .../src/components/{ => client}/Layout.vue | 0 .../{ => client}/LayoutDashboard.vue | 89 +- .../{ => client}/ui/Card/CardComponent.vue | 0 .../src/components/{ => client}/ui/Modal.vue | 0 .../{ => client}/ui/Table/TableTanstack.vue | 0 .../{ => client}/ui/Table/ViewButton.vue | 0 .../{ => client}/ui/TextForms/SelectInput.vue | 0 .../{ => client}/ui/TextForms/TextInput.vue | 0 frontend/src/mythicalclient/Permissions.ts | 5 + frontend/src/router/index.ts | 113 +-- frontend/src/views/admin/Addons.vue | 79 -- frontend/src/views/admin/Apikeys.vue | 83 -- frontend/src/views/admin/Backups.vue | 69 -- frontend/src/views/admin/Eula.vue | 185 ---- frontend/src/views/admin/Home.vue | 315 +------ frontend/src/views/admin/Languages.vue | 68 -- frontend/src/views/admin/Logs.vue | 69 -- frontend/src/views/admin/Roles.vue | 75 -- frontend/src/views/admin/Settings.vue | 84 -- frontend/src/views/admin/Tickets.vue | 88 -- frontend/src/views/admin/Users.vue | 86 -- frontend/src/views/admin/announcements.vue | 90 -- frontend/src/views/{ => client}/Account.vue | 14 +- frontend/src/views/{ => client}/Home.vue | 4 +- .../{ => client}/auth/ForgotPassword.vue | 6 +- .../src/views/{ => client}/auth/Login.vue | 6 +- .../src/views/{ => client}/auth/Register.vue | 6 +- .../views/{ => client}/auth/ResetPassword.vue | 6 +- .../{ => client}/auth/TwoFactorSetup.vue | 6 +- .../{ => client}/auth/TwoFactorVerify.vue | 6 +- frontend/src/views/{ => client}/auth/sso.vue | 6 +- .../views/{ => client}/errors/Forbidden.vue | 2 +- .../views/{ => client}/errors/NotFound.vue | 2 +- .../views/{ => client}/errors/ServerError.vue | 2 +- .../src/views/{ => client}/ticket/List.vue | 4 +- .../src/views/{ => client}/ticket/[id].vue | 4 +- frontend/vite.config.ts | 22 +- frontend/yarn.lock | 884 ++++++++++-------- mythicalclient | 4 + 62 files changed, 1096 insertions(+), 1844 deletions(-) create mode 100755 backend/app/MythicalSystems/Telemetry.php create mode 100755 backend/app/MythicalSystems/TelemetryCollection.php create mode 100755 frontend/src/components/admin/LayoutDashboard.vue rename frontend/src/components/{ => client}/Auth/FormCard.vue (100%) rename frontend/src/components/{ => client}/Auth/FormInput.vue (100%) rename frontend/src/components/{ => client}/Dashboard/Account/Activities.vue (95%) rename frontend/src/components/{ => client}/Dashboard/Account/ApiKeys.vue (94%) rename frontend/src/components/{ => client}/Dashboard/Account/Billing.vue (98%) rename frontend/src/components/{ => client}/Dashboard/Account/Layout.vue (100%) rename frontend/src/components/{ => client}/Dashboard/Account/Mails.vue (92%) rename frontend/src/components/{ => client}/Dashboard/Account/Security.vue (96%) rename frontend/src/components/{ => client}/Dashboard/Account/Settings.vue (98%) rename frontend/src/components/{ => client}/Dashboard/Admin/Settings/Advanced.vue (96%) rename frontend/src/components/{ => client}/Dashboard/Admin/Settings/CloudFlare.vue (95%) rename frontend/src/components/{ => client}/Dashboard/Admin/Settings/Dashboard.vue (96%) rename frontend/src/components/{ => client}/Dashboard/Admin/Settings/Email.vue (95%) rename frontend/src/components/{ => client}/Errors/ErrorPage.vue (100%) rename frontend/src/components/{ => client}/Layout.vue (100%) rename frontend/src/components/{ => client}/LayoutDashboard.vue (87%) rename frontend/src/components/{ => client}/ui/Card/CardComponent.vue (100%) rename frontend/src/components/{ => client}/ui/Modal.vue (100%) rename frontend/src/components/{ => client}/ui/Table/TableTanstack.vue (100%) rename frontend/src/components/{ => client}/ui/Table/ViewButton.vue (100%) rename frontend/src/components/{ => client}/ui/TextForms/SelectInput.vue (100%) rename frontend/src/components/{ => client}/ui/TextForms/TextInput.vue (100%) create mode 100755 frontend/src/mythicalclient/Permissions.ts delete mode 100755 frontend/src/views/admin/Addons.vue delete mode 100755 frontend/src/views/admin/Apikeys.vue delete mode 100755 frontend/src/views/admin/Backups.vue delete mode 100755 frontend/src/views/admin/Eula.vue delete mode 100755 frontend/src/views/admin/Languages.vue delete mode 100755 frontend/src/views/admin/Logs.vue delete mode 100755 frontend/src/views/admin/Roles.vue delete mode 100755 frontend/src/views/admin/Settings.vue delete mode 100755 frontend/src/views/admin/Tickets.vue delete mode 100755 frontend/src/views/admin/Users.vue delete mode 100755 frontend/src/views/admin/announcements.vue rename frontend/src/views/{ => client}/Account.vue (80%) rename frontend/src/views/{ => client}/Home.vue (97%) rename frontend/src/views/{ => client}/auth/ForgotPassword.vue (96%) rename frontend/src/views/{ => client}/auth/Login.vue (97%) rename frontend/src/views/{ => client}/auth/Register.vue (97%) rename frontend/src/views/{ => client}/auth/ResetPassword.vue (96%) rename frontend/src/views/{ => client}/auth/TwoFactorSetup.vue (96%) rename frontend/src/views/{ => client}/auth/TwoFactorVerify.vue (95%) rename frontend/src/views/{ => client}/auth/sso.vue (93%) rename frontend/src/views/{ => client}/errors/Forbidden.vue (84%) rename frontend/src/views/{ => client}/errors/NotFound.vue (84%) rename frontend/src/views/{ => client}/errors/ServerError.vue (84%) rename frontend/src/views/{ => client}/ticket/List.vue (94%) rename frontend/src/views/{ => client}/ticket/[id].vue (97%) diff --git a/backend/app/Api/User/Auth/ResetPassword.php b/backend/app/Api/User/Auth/ResetPassword.php index 2c0ac1d..749ef12 100755 --- a/backend/app/Api/User/Auth/ResetPassword.php +++ b/backend/app/Api/User/Auth/ResetPassword.php @@ -111,11 +111,12 @@ if (User::updateInfo($userToken, UserColumns::PASSWORD, $password, true) == true) { Verification::delete($code); + $token = App::getInstance(true)->encrypt(date('Y-m-d H:i:s') . $uuid . random_bytes(16) . base64_encode($code)); + User::updateInfo($userToken, UserColumns::ACCOUNT_TOKEN, $token, true); $appInstance->OK('Password has been reset', []); } else { $appInstance->BadRequest('Failed to reset password', ['error_code' => 'FAILED_TO_RESET_PASSWORD']); } - } else { $appInstance->BadRequest('Bad Request', ['error_code' => 'INVALID_CODE']); } diff --git a/backend/app/Api/User/Session.php b/backend/app/Api/User/Session.php index 7d8a2b5..b7dbca8 100755 --- a/backend/app/Api/User/Session.php +++ b/backend/app/Api/User/Session.php @@ -172,7 +172,7 @@ 'first_seen' => User::getInfo($accountToken, UserColumns::FIRST_SEEN, false), 'background' => User::getInfo($accountToken, UserColumns::BACKGROUND, false), 'role_name' => Roles::getUserRoleName(User::getInfo($accountToken, UserColumns::UUID, false)), - 'role_real_name' => Roles::getUserRoleName(User::getInfo($accountToken, UserColumns::UUID, false)), + 'role_real_name' => strtolower(Roles::getUserRoleName(User::getInfo($accountToken, UserColumns::UUID, false))), ], 'billing' => $billing, ]); diff --git a/backend/app/Chat/User.php b/backend/app/Chat/User.php index e03cf12..84db168 100755 --- a/backend/app/Chat/User.php +++ b/backend/app/Chat/User.php @@ -111,7 +111,7 @@ public static function register(string $username, string $password, string $emai ':banned' => 'NO', ':verified' => 'false', ]); - + \MythicalClient\MythicalSystems\Telemetry::send(\MythicalClient\MythicalSystems\TelemetryCollection::USER_NEW); /** * Check if the mail is enabled. * diff --git a/backend/app/MythicalSystems/Telemetry.php b/backend/app/MythicalSystems/Telemetry.php new file mode 100755 index 0000000..cbfcbdb --- /dev/null +++ b/backend/app/MythicalSystems/Telemetry.php @@ -0,0 +1,48 @@ +getLogger()->debug('Sending telemetry data: ' . $telemetryCollection); + $url = sprintf( + "https://api.mythicalsystems.xyz/telemetry?authKey=%s&project=%s&action=%s&osName=%s&kernelName=%s&cpuArchitecture=%s&osArchitecture=%s", + "AxWTnecj85SI4bG6rIP8bvw2uCF7W5MmkJcQIkrYS80MzeTraQWyICL690XOio8F", + "mythicalclient", + urlencode((string) $telemetryCollection), + urlencode(SYSTEM_OS_NAME), + urlencode(SYSTEM_KERNEL_NAME), + "amd", + "64" + ); + + $curl = curl_init(); + curl_setopt_array($curl, [ + CURLOPT_URL => $url, + CURLOPT_RETURNTRANSFER => true, + CURLOPT_ENCODING => "", + CURLOPT_MAXREDIRS => 10, + CURLOPT_TIMEOUT => 10, + CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, + CURLOPT_CUSTOMREQUEST => "GET", + CURLOPT_POSTFIELDS => "", + CURLOPT_HTTPHEADER => [ + "Content-Type: application/json", + "User-Agent: mythicalclient/" . APP_VERSION + ], + ]); + + curl_exec($curl); + curl_close($curl); + } catch (\Exception $e) { + App::getInstance(true)->getLogger()->debug("Failed to send telemetry data: ". $e->getMessage()); + // No one cares! + } + } +} + diff --git a/backend/app/MythicalSystems/TelemetryCollection.php b/backend/app/MythicalSystems/TelemetryCollection.php new file mode 100755 index 0000000..070a279 --- /dev/null +++ b/backend/app/MythicalSystems/TelemetryCollection.php @@ -0,0 +1,10 @@ + +
+ + + + + + + +
+ +
+
+ + + + + +
+ +
+ +
+ + {{ item.name }} + +
+
+
+ + +
+
+ +
+
+ + + +
+
+ + + + + diff --git a/frontend/src/components/Auth/FormCard.vue b/frontend/src/components/client/Auth/FormCard.vue similarity index 100% rename from frontend/src/components/Auth/FormCard.vue rename to frontend/src/components/client/Auth/FormCard.vue diff --git a/frontend/src/components/Auth/FormInput.vue b/frontend/src/components/client/Auth/FormInput.vue similarity index 100% rename from frontend/src/components/Auth/FormInput.vue rename to frontend/src/components/client/Auth/FormInput.vue diff --git a/frontend/src/components/Dashboard/Account/Activities.vue b/frontend/src/components/client/Dashboard/Account/Activities.vue similarity index 95% rename from frontend/src/components/Dashboard/Account/Activities.vue rename to frontend/src/components/client/Dashboard/Account/Activities.vue index be70ebe..182f849 100755 --- a/frontend/src/components/Dashboard/Account/Activities.vue +++ b/frontend/src/components/client/Dashboard/Account/Activities.vue @@ -1,6 +1,6 @@ diff --git a/frontend/src/views/admin/Apikeys.vue b/frontend/src/views/admin/Apikeys.vue deleted file mode 100755 index f1b6f71..0000000 --- a/frontend/src/views/admin/Apikeys.vue +++ /dev/null @@ -1,83 +0,0 @@ - - - diff --git a/frontend/src/views/admin/Backups.vue b/frontend/src/views/admin/Backups.vue deleted file mode 100755 index 3ca2f2a..0000000 --- a/frontend/src/views/admin/Backups.vue +++ /dev/null @@ -1,69 +0,0 @@ - - - diff --git a/frontend/src/views/admin/Eula.vue b/frontend/src/views/admin/Eula.vue deleted file mode 100755 index 2805e7d..0000000 --- a/frontend/src/views/admin/Eula.vue +++ /dev/null @@ -1,185 +0,0 @@ - - - - - diff --git a/frontend/src/views/admin/Home.vue b/frontend/src/views/admin/Home.vue index e05d434..216ed5c 100755 --- a/frontend/src/views/admin/Home.vue +++ b/frontend/src/views/admin/Home.vue @@ -1,294 +1,55 @@ - diff --git a/frontend/src/views/admin/Languages.vue b/frontend/src/views/admin/Languages.vue deleted file mode 100755 index ea74579..0000000 --- a/frontend/src/views/admin/Languages.vue +++ /dev/null @@ -1,68 +0,0 @@ - - diff --git a/frontend/src/views/admin/Logs.vue b/frontend/src/views/admin/Logs.vue deleted file mode 100755 index ca70311..0000000 --- a/frontend/src/views/admin/Logs.vue +++ /dev/null @@ -1,69 +0,0 @@ - - diff --git a/frontend/src/views/admin/Roles.vue b/frontend/src/views/admin/Roles.vue deleted file mode 100755 index d65cfed..0000000 --- a/frontend/src/views/admin/Roles.vue +++ /dev/null @@ -1,75 +0,0 @@ - - diff --git a/frontend/src/views/admin/Settings.vue b/frontend/src/views/admin/Settings.vue deleted file mode 100755 index 4f982fd..0000000 --- a/frontend/src/views/admin/Settings.vue +++ /dev/null @@ -1,84 +0,0 @@ - - - - diff --git a/frontend/src/views/admin/Tickets.vue b/frontend/src/views/admin/Tickets.vue deleted file mode 100755 index 852d5d4..0000000 --- a/frontend/src/views/admin/Tickets.vue +++ /dev/null @@ -1,88 +0,0 @@ - - diff --git a/frontend/src/views/admin/Users.vue b/frontend/src/views/admin/Users.vue deleted file mode 100755 index c8a2ae6..0000000 --- a/frontend/src/views/admin/Users.vue +++ /dev/null @@ -1,86 +0,0 @@ - - - - - diff --git a/frontend/src/views/admin/announcements.vue b/frontend/src/views/admin/announcements.vue deleted file mode 100755 index eaa4317..0000000 --- a/frontend/src/views/admin/announcements.vue +++ /dev/null @@ -1,90 +0,0 @@ - - diff --git a/frontend/src/views/Account.vue b/frontend/src/views/client/Account.vue similarity index 80% rename from frontend/src/views/Account.vue rename to frontend/src/views/client/Account.vue index 9c51778..fd7332e 100755 --- a/frontend/src/views/Account.vue +++ b/frontend/src/views/client/Account.vue @@ -30,13 +30,13 @@ diff --git a/frontend/src/views/errors/NotFound.vue b/frontend/src/views/client/errors/NotFound.vue similarity index 84% rename from frontend/src/views/errors/NotFound.vue rename to frontend/src/views/client/errors/NotFound.vue index da93097..2d3804e 100755 --- a/frontend/src/views/errors/NotFound.vue +++ b/frontend/src/views/client/errors/NotFound.vue @@ -1,6 +1,6 @@