Skip to content

Commit

Permalink
PUSH
Browse files Browse the repository at this point in the history
-> Better file structure
-> Account token resets on password change!
-> Fix the real user role is not really real user!
-> Telemetry
  • Loading branch information
NaysKutzu committed Dec 8, 2024
1 parent 9662afe commit 05ccffc
Show file tree
Hide file tree
Showing 62 changed files with 1,096 additions and 1,844 deletions.
3 changes: 2 additions & 1 deletion backend/app/Api/User/Auth/ResetPassword.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
}
Expand Down
2 changes: 1 addition & 1 deletion backend/app/Api/User/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
Expand Down
2 changes: 1 addition & 1 deletion backend/app/Chat/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
48 changes: 48 additions & 0 deletions backend/app/MythicalSystems/Telemetry.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace MythicalClient\MythicalSystems;

use MythicalClient\App;

class Telemetry implements TelemetryCollection
{
public static function send(TelemetryCollection|string $telemetryCollection): void
{
try {
App::getInstance(true)->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!
}
}
}

10 changes: 10 additions & 0 deletions backend/app/MythicalSystems/TelemetryCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace MythicalClient\MythicalSystems;

interface TelemetryCollection {
public const USER_NEW = "user:new";
public const SERVICE_NEW = "service:new";
public const TICKET_OPEN = "ticket:open";

}
4 changes: 4 additions & 0 deletions backend/mythicalclient
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ if (!empty($_SERVER['DOCUMENT_ROOT'])) {
define("ENV_PATH", APP_PUBLIC."/../storage/");
define('APP_START', microtime(true));
define('APP_DIR', APP_PUBLIC.'/');
define('SYSTEM_OS_NAME', gethostname().'/'.PHP_OS_FAMILY);
define('SYSTEM_KERNEL_NAME', php_uname('s'));
define('APP_VERSION', "dev");
define("TELEMETRY", true);

require_once __DIR__ . "/boot/kernel.php";

Expand Down
4 changes: 4 additions & 0 deletions backend/public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@
define('APP_SOURCECODE_DIR', APP_DIR . 'app');
define('APP_ROUTES_DIR', APP_SOURCECODE_DIR . '/Api');
define('APP_DEBUG', true);
define('SYSTEM_OS_NAME', gethostname().'/'.PHP_OS_FAMILY);
define('SYSTEM_KERNEL_NAME', php_uname('s'));
define('APP_VERSION', "dev");
define("TELEMETRY", true);
/**
* Require the kernel.
*/
Expand Down
4 changes: 2 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
"@vueuse/sound": "^2.0.1",
"date-fns": "^4.1.0",
"js-cookie": "^3.0.5",
"lucide-vue": "^0.454.0",
"lucide-vue-next": "^0.454.0",
"lucide-vue-next": "^0.468.0",
"qrcode": "^1.5.4",
"vue": "^3.5.12",
"vue-i18n": "^10.0.5",
Expand All @@ -43,6 +42,7 @@
"npm-run-all2": "^7.0.1",
"postcss": "^8.4.49",
"prettier": "^3.3.3",
"rollup-plugin-visualizer": "^5.12.0",
"tailwindcss": "^3.4.15",
"typescript": "~5.6.3",
"vite": "^5.4.10",
Expand Down
Loading

0 comments on commit 05ccffc

Please sign in to comment.