Be able to disable the login form for specific users

This commit is contained in:
Frederic Guillot
2015-02-07 23:28:17 -05:00
parent 607d9dc794
commit 00b9508d81
25 changed files with 148 additions and 69 deletions

View File

@@ -30,9 +30,14 @@ class Database extends Base
*/
public function authenticate($username, $password)
{
$user = $this->db->table(User::TABLE)->eq('username', $username)->eq('is_ldap_user', 0)->findOne();
$user = $this->db
->table(User::TABLE)
->eq('username', $username)
->eq('disable_login_form', 0)
->eq('is_ldap_user', 0)
->findOne();
if ($user && password_verify($password, $user['password'])) {
if (is_array($user) && password_verify($password, $user['password'])) {
$this->userSession->refresh($user);
$this->container['dispatcher']->dispatch('auth.success', new AuthEvent(self::AUTH_NAME, $user['id']));
return true;

View File

@@ -66,6 +66,7 @@ class ReverseProxy extends Base
'username' => $login,
'is_admin' => REVERSE_PROXY_DEFAULT_ADMIN === $login,
'is_ldap_user' => 1,
'disable_login_form' => 1,
));
}
}

View File

@@ -341,7 +341,7 @@ class User extends Base
if ($this->request->isPost()) {
$values = $this->request->getValues();
$values = $this->request->getValues() + array('disable_login_form' => 0);
if ($this->userSession->isAdmin()) {
$values += array('is_admin' => 0);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -715,4 +715,5 @@ return array(
'Show/hide projects' => 'Afficher/cacher les projets',
'Show/hide subtasks' => 'Afficher/cacher les sous-tâches',
'Show/hide tasks' => 'Afficher/cacher les tâches',
'Disable login form' => 'Désactiver le formulaire d\'authentification',
);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
// 'Disable login form' => '',
);

View File

@@ -5,7 +5,12 @@ namespace Schema;
use PDO;
use Core\Security;
const VERSION = 43;
const VERSION = 44;
function version_44($pdo)
{
$pdo->exec('ALTER TABLE users ADD COLUMN disable_login_form TINYINT(1) DEFAULT 0');
}
function version_43($pdo)
{

View File

@@ -5,7 +5,12 @@ namespace Schema;
use PDO;
use Core\Security;
const VERSION = 24;
const VERSION = 25;
function version_25($pdo)
{
$pdo->exec("ALTER TABLE users ADD COLUMN disable_login_form BOOLEAN DEFAULT '1'");
}
function version_24($pdo)
{
@@ -13,17 +18,17 @@ function version_24($pdo)
$rq->execute(array('subtask_restriction', '0'));
$rq->execute(array('subtask_time_tracking', '0'));
$pdo->exec("
$pdo->exec('
CREATE TABLE subtask_time_tracking (
id SERIAL PRIMARY KEY,
user_id INTEGER NOT NULL,
subtask_id INTEGER NOT NULL,
start INTEGER DEFAULT 0,
end INTEGER DEFAULT 0,
"user_id" INTEGER NOT NULL,
"subtask_id" INTEGER NOT NULL,
"start" INTEGER DEFAULT 0,
"end" INTEGER DEFAULT 0,
FOREIGN KEY(user_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY(subtask_id) REFERENCES task_has_subtasks(id) ON DELETE CASCADE
)
");
');
}
function version_23($pdo)

View File

@@ -5,7 +5,12 @@ namespace Schema;
use Core\Security;
use PDO;
const VERSION = 42;
const VERSION = 43;
function version_43($pdo)
{
$pdo->exec('ALTER TABLE users ADD COLUMN disable_login_form INTEGER DEFAULT 0');
}
function version_42($pdo)
{

View File

@@ -26,9 +26,13 @@
<?= $this->formLabel(t('Language'), 'language') ?>
<?= $this->formSelect('language', $languages, $values, $errors) ?><br/>
<?php if ($this->userSession->isAdmin()): ?>
<?= $this->formCheckbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?><br/>
<?php endif ?>
<div class="alert alert-error">
<?= $this->formCheckbox('disable_login_form', t('Disable login form'), 1, isset($values['disable_login_form']) && $values['disable_login_form'] == 1) ?><br/>
<?php if ($this->userSession->isAdmin()): ?>
<?= $this->formCheckbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1) ?><br/>
<?php endif ?>
</div>
<div class="form-actions">
<input type="submit" value="<?= t('Save') ?>" class="btn btn-blue"/>