summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-02-07 23:28:17 -0500
committerFrederic Guillot <fred@kanboard.net>2015-02-07 23:28:17 -0500
commit00b9508d8178bae016b2a25a81282dbe9ae0a9d2 (patch)
tree488397b9830b9ee56ff3eb4752958ea7a44eec04 /app
parent607d9dc79429cefa51dfe1739564922cc9a2ab89 (diff)
Be able to disable the login form for specific users
Diffstat (limited to 'app')
-rw-r--r--app/Auth/Database.php9
-rw-r--r--app/Auth/ReverseProxy.php1
-rw-r--r--app/Controller/User.php2
-rw-r--r--app/Locale/da_DK/translations.php1
-rw-r--r--app/Locale/de_DE/translations.php1
-rw-r--r--app/Locale/es_ES/translations.php1
-rw-r--r--app/Locale/fi_FI/translations.php1
-rw-r--r--app/Locale/fr_FR/translations.php1
-rw-r--r--app/Locale/hu_HU/translations.php1
-rw-r--r--app/Locale/it_IT/translations.php1
-rw-r--r--app/Locale/ja_JP/translations.php1
-rw-r--r--app/Locale/pl_PL/translations.php1
-rw-r--r--app/Locale/pt_BR/translations.php1
-rw-r--r--app/Locale/ru_RU/translations.php1
-rw-r--r--app/Locale/sv_SE/translations.php1
-rw-r--r--app/Locale/th_TH/translations.php1
-rw-r--r--app/Locale/zh_CN/translations.php1
-rw-r--r--app/Schema/Mysql.php7
-rw-r--r--app/Schema/Postgres.php19
-rw-r--r--app/Schema/Sqlite.php7
-rw-r--r--app/Template/user/edit.php10
21 files changed, 54 insertions, 15 deletions
diff --git a/app/Auth/Database.php b/app/Auth/Database.php
index 2804b9a8..e69f18a9 100644
--- a/app/Auth/Database.php
+++ b/app/Auth/Database.php
@@ -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;
diff --git a/app/Auth/ReverseProxy.php b/app/Auth/ReverseProxy.php
index b84550cf..6cd01b28 100644
--- a/app/Auth/ReverseProxy.php
+++ b/app/Auth/ReverseProxy.php
@@ -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,
));
}
}
diff --git a/app/Controller/User.php b/app/Controller/User.php
index 3d44f226..91141241 100644
--- a/app/Controller/User.php
+++ b/app/Controller/User.php
@@ -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);
diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php
index 7e2d03a0..45611dcd 100644
--- a/app/Locale/da_DK/translations.php
+++ b/app/Locale/da_DK/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php
index e4838ba4..6570f154 100644
--- a/app/Locale/de_DE/translations.php
+++ b/app/Locale/de_DE/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php
index 67907e73..91eeab00 100644
--- a/app/Locale/es_ES/translations.php
+++ b/app/Locale/es_ES/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php
index 01424a6f..4db578dd 100644
--- a/app/Locale/fi_FI/translations.php
+++ b/app/Locale/fi_FI/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php
index dd02cd7f..90eb87af 100644
--- a/app/Locale/fr_FR/translations.php
+++ b/app/Locale/fr_FR/translations.php
@@ -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',
);
diff --git a/app/Locale/hu_HU/translations.php b/app/Locale/hu_HU/translations.php
index d051be30..252e57ef 100644
--- a/app/Locale/hu_HU/translations.php
+++ b/app/Locale/hu_HU/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php
index 64eb201a..4f0e6bc5 100644
--- a/app/Locale/it_IT/translations.php
+++ b/app/Locale/it_IT/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php
index 68f2bbc3..a71bffdd 100644
--- a/app/Locale/ja_JP/translations.php
+++ b/app/Locale/ja_JP/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php
index 5ff27109..49fb3272 100644
--- a/app/Locale/pl_PL/translations.php
+++ b/app/Locale/pl_PL/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php
index 73966572..bd327f0b 100644
--- a/app/Locale/pt_BR/translations.php
+++ b/app/Locale/pt_BR/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php
index e644aa5d..1042830d 100644
--- a/app/Locale/ru_RU/translations.php
+++ b/app/Locale/ru_RU/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php
index 8bab7cdf..cdae7fde 100644
--- a/app/Locale/sv_SE/translations.php
+++ b/app/Locale/sv_SE/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php
index ef2df8e8..54d94519 100644
--- a/app/Locale/th_TH/translations.php
+++ b/app/Locale/th_TH/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php
index ffea13d4..2a2bc0b8 100644
--- a/app/Locale/zh_CN/translations.php
+++ b/app/Locale/zh_CN/translations.php
@@ -713,4 +713,5 @@ return array(
// 'Show/hide projects' => '',
// 'Show/hide subtasks' => '',
// 'Show/hide tasks' => '',
+ // 'Disable login form' => '',
);
diff --git a/app/Schema/Mysql.php b/app/Schema/Mysql.php
index 5a52288b..9c066625 100644
--- a/app/Schema/Mysql.php
+++ b/app/Schema/Mysql.php
@@ -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)
{
diff --git a/app/Schema/Postgres.php b/app/Schema/Postgres.php
index 7aa1c457..52130c96 100644
--- a/app/Schema/Postgres.php
+++ b/app/Schema/Postgres.php
@@ -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)
diff --git a/app/Schema/Sqlite.php b/app/Schema/Sqlite.php
index 17166e64..37483945 100644
--- a/app/Schema/Sqlite.php
+++ b/app/Schema/Sqlite.php
@@ -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)
{
diff --git a/app/Template/user/edit.php b/app/Template/user/edit.php
index 310a1ed0..bd1c4889 100644
--- a/app/Template/user/edit.php
+++ b/app/Template/user/edit.php
@@ -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"/>