From c52e9b33d2a31843c04fa1bc8a982acc2da7e2ff Mon Sep 17 00:00:00 2001 From: Deon George Date: Thu, 16 May 2013 21:50:30 +1000 Subject: [PATCH] Modalise login --- application/classes/Auth/OSB.php | 17 +++++++++++++++++ application/classes/Controller/Login.php | 7 +++---- application/views/pages/login_reset.php | 6 +++--- application/views/pages/login_reset_sent.php | 4 ++-- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/application/classes/Auth/OSB.php b/application/classes/Auth/OSB.php index 9e87c5b6..0243420a 100644 --- a/application/classes/Auth/OSB.php +++ b/application/classes/Auth/OSB.php @@ -10,6 +10,19 @@ * @license http://dev.osbill.net/license.html */ class Auth_OSB extends Auth_ORM { + /** + * We need to override Kohana's __construct(), for tasks, which attempt to open a session + * and probably dont have access to PHP sessions path. + * Tasks dont need sessions anyway? + */ + public function __construct($config = array()) { + // Save the config in the object + $this->_config = $config; + + if (PHP_SAPI !== 'cli') + parent::__construct($config); + } + /** * Get the user that a token applies to * @@ -181,6 +194,10 @@ class Auth_OSB extends Auth_ORM { public function logged_in($role=NULL,$debug=NULL) { $status = FALSE; + // If we are a CLI, we are not logged in + if (PHP_SAPI === 'cli') + return $status; + // Get the user from the session $uo = $this->get_user(); diff --git a/application/classes/Controller/Login.php b/application/classes/Controller/Login.php index aed7c471..b9eb8042 100644 --- a/application/classes/Controller/Login.php +++ b/application/classes/Controller/Login.php @@ -72,21 +72,20 @@ class Controller_Login extends lnApp_Controller_Login { // Show our token screen even if the email was invalid. if (isset($_POST['username'])) - Block::factory() - ->body(View::factory('pages/login_reset_sent')); + $output = View::factory('pages/login_reset_sent'); else HTTP::redirect('login'); } else { - Block::factory() - ->body(View::factory('pages/login_reset')); + $output = View::factory('pages/login_reset'); } Style::factory() ->type('file') ->data('media/theme/baseadmin/css/pages/login.css'); + $this->template->content = $output; $this->template->shownavbar = FALSE; } } diff --git a/application/views/pages/login_reset.php b/application/views/pages/login_reset.php index dacf160b..5ae381d9 100644 --- a/application/views/pages/login_reset.php +++ b/application/views/pages/login_reset.php @@ -1,15 +1,15 @@
-
+

Reset Password

If you have forgotten your password, we can issue you a temporary access code via email that will allow you to change your password.

diff --git a/application/views/pages/login_reset_sent.php b/application/views/pages/login_reset_sent.php index 4b8d32fd..124d7865 100644 --- a/application/views/pages/login_reset_sent.php +++ b/application/views/pages/login_reset_sent.php @@ -1,13 +1,13 @@