use radio buttons to select the login database
allows one click logins to not default databases using passwordmanagers like keefox.
This commit is contained in:
parent
816b793e4c
commit
76825cb673
@ -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');
|
||||
|
@ -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 '<label><input type="radio" name="'.$name.'" class="'.$class.'" value="'.escape($value).'" '.($selected ? 'selected="selected"' : '').'>'.escape($label).'</label>';
|
||||
return '<label><input type="radio" name="'.$name.'" class="'.$class.'" value="'.escape($value).'" '.($checked ? 'checked' : '').'>'.escape($label).'</label>';
|
||||
}
|
||||
|
||||
function form_checkbox($name, $label, $value, $checked = false, $class = '')
|
||||
|
@ -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;
|
||||
|
||||
|
@ -34,17 +34,9 @@
|
||||
<?php if (ENABLE_MULTIPLE_DB && count($databases) > 1): ?>
|
||||
<div id="database-selector">
|
||||
<h4><?= t('Select another database') ?></h4>
|
||||
<ul>
|
||||
<?php foreach ($databases as $filename => $dbname): ?>
|
||||
<li>
|
||||
<?php if ($current_database === $filename): ?>
|
||||
<strong><?= Helper\escape($dbname) ?></strong>
|
||||
<?php else: ?>
|
||||
<a href="?action=select-db&database=<?= Helper\escape($filename) ?>"><?= Helper\escape($dbname) ?></a>
|
||||
<?php endif ?>
|
||||
</li>
|
||||
<?= Helper\form_radio('database', $dbname, $filename, ($current_database === $filename)) ?>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user