From 76825cb6738b1834b5508cb36d141b5fd65ee28f Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Sun, 18 Jan 2015 01:53:54 +0100 Subject: [PATCH] use radio buttons to select the login database allows one click logins to not default databases using passwordmanagers like keefox. --- controllers/common.php | 13 +++++++++---- lib/helpers.php | 4 ++-- models/database.php | 2 +- templates/login.php | 14 +++----------- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/controllers/common.php b/controllers/common.php index dcefa2a..e622a84 100644 --- a/controllers/common.php +++ b/controllers/common.php @@ -11,9 +11,14 @@ Router\before(function($action) { Session\open(BASE_URL_DIRECTORY, SESSION_SAVE_PATH, 0); - // Select the requested database. If it fails, logout to destroy session and + // Select the requested database either from post param database or from the + // session variable. If it fails, logout to destroy session and // 'remember me' cookie - if (! empty($_SESSION['database'])) { + if (! empty(Request\value('database')) && ! Model\Database\select(Request\value('database'))) { + Model\User\logout(); + Response\redirect('?action=login'); + } + elseif (! empty($_SESSION['database'])) { if (! Model\Database\select($_SESSION['database'])) { Model\User\logout(); Response\redirect('?action=login'); @@ -29,13 +34,13 @@ Router\before(function($action) { Response\redirect('?action=login'); } } - else if (Model\RememberMe\has_cookie()) { + elseif (Model\RememberMe\has_cookie()) { Model\RememberMe\refresh(); } // Load translations $language = Model\Config\get('language') ?: 'en_US'; - + if ($language !== 'en_US') { Translator\load($language); } diff --git a/lib/helpers.php b/lib/helpers.php index bbb1c64..604da2d 100644 --- a/lib/helpers.php +++ b/lib/helpers.php @@ -229,9 +229,9 @@ function form_radios($name, array $options, array $values = array()) return $html; } -function form_radio($name, $label, $value, $selected = false, $class = '') +function form_radio($name, $label, $value, $checked = false, $class = '') { - return ''; + return ''; } function form_checkbox($name, $label, $value, $checked = false, $class = '') diff --git a/models/database.php b/models/database.php index c345aeb..f681af3 100644 --- a/models/database.php +++ b/models/database.php @@ -41,7 +41,7 @@ function select($filename = '') // function gets called with a filename at least once the database // connection is established - if ($filename !== '') { + if (! empty($filename)) { if (ENABLE_MULTIPLE_DB && in_array($filename, get_all())) { $current_filename = $filename; diff --git a/templates/login.php b/templates/login.php index f129b0e..7f5312f 100644 --- a/templates/login.php +++ b/templates/login.php @@ -34,17 +34,9 @@ 1): ?>

- + $dbname): ?> + +