From a850ed911d476c0490f2498eb1f985740c8cf2b8 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Mon, 19 Dec 2011 15:05:47 +0000 Subject: [PATCH] Add login page. --- source/webui/pages/login.php | 30 ++++++++++++++++++++++++++++++ source/webui/templates/login.tpl | 17 +++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 source/webui/pages/login.php create mode 100644 source/webui/templates/login.tpl diff --git a/source/webui/pages/login.php b/source/webui/pages/login.php new file mode 100644 index 0000000..1452db1 --- /dev/null +++ b/source/webui/pages/login.php @@ -0,0 +1,30 @@ +request(); +$auth = $main->auth(); + +$authenticated = false; +$authentication_failed = false; + +if ($request->exists('do')) { + $username = StatusBoard_Main::issetelse($_POST['username'], Sihnon_Exception_InvalidParameters); + $password = StatusBoard_Main::issetelse($_POST['username'], Sihnon_Exception_InvalidParameters); + + try { + $auth->authenticate($username, $password); + $authenticated = true; + + StatusBoard_Page::redirect('home'); + + } catch (Sihnon_Exception_UnknownUser $e) { + $authentication_failed = true; + } catch (Sihnon_Exception_IncorrectPassword $e) { + $authentication_failed = true; + } +} + +$this->smarty->assign('authentication', $authenticated); +$this->smarty->assign('authentication_failed', $authentication_failed); + +?> \ No newline at end of file diff --git a/source/webui/templates/login.tpl b/source/webui/templates/login.tpl new file mode 100644 index 0000000..8cf530a --- /dev/null +++ b/source/webui/templates/login.tpl @@ -0,0 +1,17 @@ +{if $authentication_failed} + +
+ Incorrect username/password combination entered. +
+ +{/if} + +
+ + + + + + + +
\ No newline at end of file