From 988628adcbbef85ebe872c36ca15355c7803fc45 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Sat, 24 Jun 2017 23:33:55 -0600 Subject: [PATCH] Add permission checks --- action.php | 5 +++++ app.php | 5 +---- index.php | 18 +++++++++++------- lang/en_us.php | 1 + required.php | 7 ++++++- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/action.php b/action.php index 7391bd0..e1a96b5 100644 --- a/action.php +++ b/action.php @@ -4,9 +4,14 @@ * Make things happen when buttons are pressed and forms submitted. */ require_once __DIR__ . "/required.php"; +require_once __DIR__ . "/lib/login.php"; dieifnotloggedin(); +if (account_has_permission($_SESSION['username'], "QWIKCLOCK") == FALSE) { + die("You don't have permission to be here."); +} + /** * Redirects back to the page ID in $_POST/$_GET['source'] with the given message ID. * The message will be displayed by the app. diff --git a/app.php b/app.php index e3bae06..00aa34c 100644 --- a/app.php +++ b/app.php @@ -1,10 +1,7 @@ "Username", "password" => "Password", "continue" => "Continue", + "no admin permission" => "You do not have permission to access this system.", "authcode" => "Authentication code", "2fa prompt" => "Enter the six-digit code from your mobile authenticator app.", "2fa incorrect" => "Authentication code incorrect.", diff --git a/required.php b/required.php index 0ea9e72..b25bcf8 100644 --- a/required.php +++ b/required.php @@ -186,6 +186,11 @@ if (!function_exists('base_url')) { function redirectIfNotLoggedIn() { if ($_SESSION['loggedin'] !== TRUE) { header('Location: ' . URL . '/index.php'); - die(); + die("You are not logged in."); + } + require_once __DIR__ . "/lib/login.php"; + if (account_has_permission($_SESSION['username'], "QWIKCLOCK") == FALSE) { + header('Location: ./index.php'); + die("You don't have permission to be here."); } }