Skip to content

Commit

Permalink
Fix login/join.
Browse files Browse the repository at this point in the history
  • Loading branch information
lewmilburn committed Nov 13, 2024
1 parent 5372edb commit 3922c80
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions Plugins/ControlPanel/Checksums.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,19 @@ class Checksums
public function Validate()
{
$CoreSettings = hash_file('sha3-512', __DIR__.'/../../Settings/Settings.php');
$CoreDeveloper = hash_file('sha3-512', __DIR__.'/../../Settings/Developer.php');

require_once __DIR__.'/Assets/ChkValues.php';
if ($Checksum['CoreSettings'] !== $CoreSettings) {
return false;
}
if ($Checksum['CoreDeveloper'] !== $CoreDeveloper) {
return false;
}

return true;
}

public function Reset()
{
$CoreSettings = hash_file('sha3-512', __DIR__.'/../../Settings/Settings.php');
$CoreDeveloper = hash_file('sha3-512', __DIR__.'/../../Settings/Developer.php');
$Data = '<?php $Checksum[\'CoreSettings\'] = \''.$CoreSettings.'\'; $Checksum[\'CoreDeveloper\'] = \''.$CoreDeveloper.'\';';
$Data = '<?php $Checksum[\'CoreSettings\'] = \''.$CoreSettings.'\';';
file_put_contents(__DIR__.'/Assets/ChkValues.php', $Data);
}
}
2 changes: 1 addition & 1 deletion Plugins/ControlPanel/Views/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<?php if (isset($_GET['success'])) { ?>
<div class="alert-success">
<div class="alert-success-icon">
<i class="fas fa-exclamation-triangle"></i>
<i class="fas fa-circle-check"></i>
</div>
<div class="alert-success-text">
<?php
Expand Down
10 changes: 7 additions & 3 deletions Processes/DefaultViews/Error.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@
<img src="<?= Out(SATURN_ROOT); ?>/Assets/Images/Saturn-logo.webp" class="w-1/4 mx-auto" alt="Logo">

<div class="pb-8">
<h1 class="text-header">
<?= __('Error'); ?> <?= Out($ErrorCode); ?>: <?= Out($ErrorName); ?>
<h1 class="text-header text-center">
<?= __('Error'); ?> <?= Out($ErrorCode); ?>
</h1>

<p class="text-body">
<p class="text-subheader-nopt text-center"><?= Out($ErrorName); ?></p>

<br>

<p class="text-error">
<?= Out($ErrorDescription); ?>
</p>
</div>
Expand Down
27 changes: 19 additions & 8 deletions Processes/Saturn/AccountManager/Join.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,29 @@
$Password = password_hash($_POST['password'], SECURITY_PASSWORD_ALGORITHM);
$UniqID = $UUID->Generate();

$Result = $DB->Insert('user', '`id`, `uuid`, `username`, `email`, `password`', "NULL, '".$UniqID."', '".$Username."', '".$Email."', '".$Password."'");
$Result = $DB->Insert('user_permissions', '`id`, `uuid`', "NULL, '".$UniqID."'");
if ($DB->Error() == null) {
header('Location: /account?success=created');
} else {
try {
$Result = $DB->Insert('user', '`id`, `uuid`, `username`, `email`, `password`', "NULL, '" . $UniqID . "', '" . $Username . "', '" . $Email . "', '" . $Password . "'");
$Result = $DB->Insert('user_permissions', '`id`, `uuid`', "NULL, '" . $UniqID . "'");
if ($DB->Error() == null) {
header('Location: /account?success=created');
} else {
$EH = new ErrorHandler();
$EH->SaturnError(
'500',
$DB->Error(),
'Database error',
'There was a problem with the database query.',
SATSYS_DOCS_URL . '/troubleshooting/errors/database#' . strtolower($DB->Error())
);
}
} catch (Exception $e) {
$EH = new ErrorHandler();
$EH->SaturnError(
'500',
$DB->Error(),
'DBMS-4',
'Database error',
'There was a problem with the database query.',
SATSYS_DOCS_URL.'/troubleshooting/errors/database#'.strtolower($DB->Error())
'There was a problem with the database query. '.$e->getMessage(),
SATSYS_DOCS_URL . '/troubleshooting/errors/database#' . strtolower($DB->Error())
);
}
} else {
Expand Down
13 changes: 12 additions & 1 deletion Processes/Saturn/DatabaseManager/DBMS.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,18 @@ public function Select(string $What, string $From, string|null $Where, string $A

public function Query(string $Query)
{
return $this->Database->Query($Query);
try {
return $this->Database->Query($Query);
} catch (\Exception $e) {
$err = new ErrorHandler();
$err->SaturnError(
'500',
'DBMS-4',
'An unexpected error occurred whilst executing the database query.',
$e->getMessage(),
SATSYS_DOCS_URL.'/troubleshooting/errors/database'
);
}
}

public function Insert(string $Into, string|null $Columns, string|null $Values): array|object|int|null
Expand Down
4 changes: 2 additions & 2 deletions Processes/Start.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
$Session = new Session();
$Session->Start();

register_shutdown_function('SaturnEnd');

function SaturnEnd(): void
{
$Actions = new Actions();
$Actions->Run('Saturn.End');
}

register_shutdown_function('SaturnEnd');

// ACTIONS
$ActionList = [];
$Actions = new Actions();
Expand Down
2 changes: 1 addition & 1 deletion index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
//
// SATURN CMS VERSION 1.0.0
// PIXELSET -- APACHE LICENSE 2.0

error_reporting(E_ALL);
require_once __DIR__.'/Processes/Load.php';
require_once __DIR__.'/Processes/Start.php';

0 comments on commit 3922c80

Please sign in to comment.