Updates (#134)
* 🐛 User not added to DB - force die() on error (#118) * 🐛 User not added to DB - force die() on error Signed-off-by: Luke Tainton <luke@tainton.uk> * Restyled by php-cs-fixer (#119) Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com> Co-authored-by: Restyled.io <commits@restyled.io> * Fixing Login Die * Broken login (#121) * Fixing Login Die * Fix Broken Login 2 * Broken login (#122) * Fixing Login Die * Fix Broken Login 2 * Update footer * Try Somethin New Today * Move break rule in footer (#124) * Update footer.php * Change line break to pipe * Remove full stop Co-authored-by: Alexander Davis <alex@adcm.uk> * ✨ Add Sentry (#127) Signed-off-by: Luke Tainton <luke@tainton.uk> * 🚧 Migrate from Sentry to GlitchTip (#129) Signed-off-by: Luke Tainton <luke@tainton.uk> * 🐛 Move opening and closing 'main' tags (#132) * 🐛 Move opening and closing 'main' tags Signed-off-by: Luke Tainton <luke@tainton.uk> * Restyled by php-cs-fixer (#133) Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com> Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Luke Tainton <luke@tainton.uk> Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com> Co-authored-by: Restyled.io <commits@restyled.io>
This commit was merged in pull request #134.
This commit is contained in:
@@ -6,6 +6,44 @@
|
||||
return $version;
|
||||
}
|
||||
|
||||
function oidc_set_vars($sub, $uid, $fname, $lname, $email)
|
||||
{
|
||||
$_SESSION['uuid'] = $sub;
|
||||
$_SESSION['username'] = $uid;
|
||||
$_SESSION['given_name'] = $fname;
|
||||
$_SESSION['family_name'] = $lname;
|
||||
$_SESSION['full_name'] = $fname . " " . $lname;
|
||||
$_SESSION['email'] = $email;
|
||||
}
|
||||
|
||||
function is_signed_in()
|
||||
{
|
||||
if (isset($_SESSION['is_signed_in'])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function user_exists($db, $uuid)
|
||||
{
|
||||
try {
|
||||
$sql = $db->prepare("SELECT uuid FROM users WHERE uuid=:uuid");
|
||||
$sql->bindParam(':uuid', $uuid);
|
||||
$sql->execute();
|
||||
$sql->setFetchMode(PDO::FETCH_ASSOC);
|
||||
$result = $sql->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
throw new Exception("Error in user_exists(): " . $e->getMessage());
|
||||
die();
|
||||
}
|
||||
if (empty($result)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function get_all_users($db)
|
||||
{
|
||||
try {
|
||||
@@ -15,7 +53,8 @@
|
||||
$sql->setFetchMode(PDO::FETCH_ASSOC);
|
||||
$result = $sql->fetchAll();
|
||||
} catch (PDOException $e) {
|
||||
echo("Error: " . $e->getMessage());
|
||||
throw new Exception("Error in get_all_users(): " . $e->getMessage());
|
||||
die();
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
@@ -31,7 +70,8 @@
|
||||
$result = $sql->fetchAll();
|
||||
$usr = $result[0]['given_name'] . " " . $result[0]['family_name'];
|
||||
} catch (PDOException $e) {
|
||||
echo("Error: " . $e->getMessage());
|
||||
throw new Exception("Error in get_user_name(): " . $e->getMessage());
|
||||
die();
|
||||
}
|
||||
return $usr;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
</main>
|
||||
<footer class="footer mt-auto py-3">
|
||||
<div class="text-center text-muted">
|
||||
<?php
|
||||
echo($_ENV['APP_NAME'] . " " . get_version());
|
||||
if ($_ENV['APP_NAME'] != "FHeD") {
|
||||
echo(", powered by FHeD");
|
||||
echo("| Powered by FHeD");
|
||||
};
|
||||
?><br>
|
||||
<?php if (is_signed_in()) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="theme-color" content="#563d7c">
|
||||
<link rel="icon" type="image/png" href="/favicon.png">
|
||||
<title><?php echo( $PAGE_TITLE ); ?></title>
|
||||
<title><?php echo($PAGE_TITLE); ?></title>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link rel="stylesheet" href="/css/bootstrap.min.css">
|
||||
@@ -19,6 +19,8 @@
|
||||
</head>
|
||||
|
||||
<body class="d-flex flex-column h-100">
|
||||
<!-- Begin page content -->
|
||||
<main role="main" class="flex-shrink-0">
|
||||
<header>
|
||||
<!-- Fixed navbar -->
|
||||
<nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark">
|
||||
@@ -32,10 +34,14 @@
|
||||
<a class="nav-link" href="/">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php if (!is_signed_in()) {echo(' disabled');} ?>" href="/new">New request</a>
|
||||
<a class="nav-link <?php if (!is_signed_in()) {
|
||||
echo(' disabled');
|
||||
} ?>" href="/new">New request</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php if (!is_signed_in()) {echo(' disabled');} ?>" href="/existing">Existing requests</a>
|
||||
<a class="nav-link <?php if (!is_signed_in()) {
|
||||
echo(' disabled');
|
||||
} ?>" href="/existing">Existing requests</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="mt-2 mt-md-0">
|
||||
|
||||
@@ -7,6 +7,15 @@ require_once __DIR__ . "/../vendor/autoload.php";
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__ . "/..");
|
||||
$dotenv->load();
|
||||
|
||||
// Custom functions
|
||||
require_once __DIR__ . "/app_functions.php";
|
||||
|
||||
// Sentry
|
||||
Sentry\init([
|
||||
'dsn' => 'https://7c4607ed5e804d08926cc0bbc0d3fbe9@app.glitchtip.com/59',
|
||||
'release' => get_version(),
|
||||
]);
|
||||
|
||||
// Database auto-generation
|
||||
if (file_exists("/../includes/install.php")) {
|
||||
return;
|
||||
@@ -34,25 +43,3 @@ if ($_ENV['OIDC_DISABLE_SSL'] == "true") {
|
||||
$oidc->setVerifyHost(false);
|
||||
$oidc->setVerifyPeer(false);
|
||||
}
|
||||
|
||||
|
||||
// Custom functions
|
||||
|
||||
require_once __DIR__ . "/app_functions.php";
|
||||
|
||||
function oidc_set_vars($sub, $uid, $fname, $lname, $email) {
|
||||
$_SESSION['uuid'] = $sub;
|
||||
$_SESSION['username'] = $uid;
|
||||
$_SESSION['given_name'] = $fname;
|
||||
$_SESSION['family_name'] = $lname;
|
||||
$_SESSION['full_name'] = $fname . " " . $lname;
|
||||
$_SESSION['email'] = $email;
|
||||
}
|
||||
|
||||
function is_signed_in() {
|
||||
if (isset($_SESSION['is_signed_in'])) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user