Summary Files Commits Branches @commit @diff @stats
path: root / src
diff options
context:
space:
mode:
Commit68808a388a61c7a778494739fe0150651a09ea66 (patch)
Author
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-04-03 09:58:18 +0300
Committer
 Syndamia <kamen.d.mladenov@protonmail.com>
2021-04-03 09:58:18 +0300
Files4109cb4b55ee11efd94563acb5e06bffee3ccbfd /src
devrix-job-board-68808a388a61c7a778494739fe0150651a09ea66.tar
devrix-job-board-68808a388a61c7a778494739fe0150651a09ea66.tar.gz
devrix-job-board-68808a388a61c7a778494739fe0150651a09ea66.zip
Parent56a5223e14f798e2c875c4347faecc4e2e9730fc (diff)
Implemented a simple login page for (admin) dashboard and skeleton of dashboard controller and view
5 files changed, 50 insertions, 0 deletions
-rw-r--r--src/controllers/DashboardController.php8
-rw-r--r--src/controllers/DashboardLoginController.php24
-rw-r--r--src/index.php5
-rw-r--r--src/views/dashboard-login.php12
-rw-r--r--src/views/dashboard.php1
diff --git a/src/controllers/DashboardController.php b/src/controllers/DashboardController.php
new file mode 100644
index 0000000..84beb14
--- /dev/null
+++ b/src/controllers/DashboardController.php
@@ -0,0 +1,8 @@
+<?php
+include_once('controllers/BaseController.php');
+
+class DashboardController extends BaseController {
+ public static function get() {
+ include "views/dashboard.php";
+ }
+}
diff --git a/src/controllers/DashboardLoginController.php b/src/controllers/DashboardLoginController.php
new file mode 100644
index 0000000..8c1cc67
--- /dev/null
+++ b/src/controllers/DashboardLoginController.php
@@ -0,0 +1,24 @@
+<?php
+include_once('controllers/BaseController.php');
+include_once('controllers/DashboardController.php');
+
+class DashboardLoginController extends BaseController {
+ private static $message;
+
+ public static function get() {
+ include "views/dashboard-login.php";
+ }
+
+ public static function post() {
+ if ($_POST['username'] == "admin" && $_POST['password'] == "admin") {
+ // Probably a bad practice, but couldn't find if it is
+ $_SERVER['REQUEST_METHOD'] = "GET";
+ // Load normal dashboard
+ DashboardController::invoke();
+ }
+ else {
+ self::$message = "Bad credentials!";
+ include "views/dashboard-login.php";
+ }
+ }
+}
diff --git a/src/index.php b/src/index.php
index b909deb..676cd56 100644
--- a/src/index.php
+++ b/src/index.php
@@ -3,6 +3,7 @@
<?php
include_once("controllers/LandingController.php");
include_once("controllers/CreateOfferController.php");
+include_once("controllers/DashboardLoginController.php");
/* The landing page practically acts as our page router.
* All request get redirected to here (look at the devrix-job-board.conf)
@@ -20,6 +21,10 @@ switch ($request) {
case "/CreateOffer/":
CreateOfferController::invoke();
break;
+ case "/Dashboard":
+ case "/Dashboard/":
+ DashboardLoginController::invoke();
+ break;
default:
http_response_code(404);
break;
diff --git a/src/views/dashboard-login.php b/src/views/dashboard-login.php
new file mode 100644
index 0000000..1431b4f
--- /dev/null
+++ b/src/views/dashboard-login.php
@@ -0,0 +1,12 @@
+<form method="post">
+ <label for="username">Username: </label>
+ <input type="text" name="username">
+ <br>
+ <label for="password">Password</label>
+ <input type="password" name="password">
+ <br>
+ <input type="submit" value="Login">
+</form>
+<?php
+ echo self::$message;
+?>
diff --git a/src/views/dashboard.php b/src/views/dashboard.php
new file mode 100644
index 0000000..86c393a
--- /dev/null
+++ b/src/views/dashboard.php
@@ -0,0 +1 @@
+<p>Dashboard works!</p>