diff options
author | Marcin Łojewski <marcin.lojewski@mlojewski.me> | 2018-06-13 21:01:09 +0300 |
---|---|---|
committer | Marcin Łojewski <marcin.lojewski@mlojewski.me> | 2018-06-13 21:01:09 +0300 |
commit | a312ba8c4705be38b48328631ee2c0d2d3d40adb (patch) | |
tree | be6765220599eac5b20de745385bb0c5b376dfd4 | |
parent | b00f61193efc3cc8340585ca70fef84a571866d4 (diff) |
User active column
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | js/settings.js | 2 | ||||
-rw-r--r-- | lib/Backend/UserBackend.php | 8 | ||||
-rw-r--r-- | lib/Constant/DB.php | 1 | ||||
-rw-r--r-- | lib/Model/User.php | 4 | ||||
-rw-r--r-- | lib/Query/QueryProvider.php | 2 | ||||
-rw-r--r-- | templates/admin.php | 1 |
8 files changed, 21 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index b5b8281..e0d1fa5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- User active column ## [4.0.0-rc1] ### Added @@ -67,6 +67,7 @@ Name | Description | Details **Home** | Home path column. | Mandatory for `Query` *Home sync* option. **Password** | Password hash column. | Mandatory for user backend. **Display name** | Display name column. | Optional. +**Active** | Flag indicating if user can log in. | Optional.<br/>Default: true. **Can change avatar** | Flag indicating if user can change its avatar. | Optional.<br/>Default: false. #### Group table @@ -161,6 +162,7 @@ User table: jhi_users Username column: login Password column: password_hash Email column: email +Active column: activated Hashing algorithm: Unix (Crypt) ``` diff --git a/js/settings.js b/js/settings.js index 0098601..87a64d5 100644 --- a/js/settings.js +++ b/js/settings.js @@ -75,7 +75,7 @@ user_sql.adminSettingsUI = function () { ); autocomplete( - "#db-table-user-column-uid, #db-table-user-column-email, #db-table-user-column-home, #db-table-user-column-password, #db-table-user-column-name, #db-table-user-column-avatar", + "#db-table-user-column-uid, #db-table-user-column-email, #db-table-user-column-home, #db-table-user-column-password, #db-table-user-column-name, #db-table-user-column-active, #db-table-user-column-avatar", "/apps/user_sql/settings/autocomplete/table/user" ); diff --git a/lib/Backend/UserBackend.php b/lib/Backend/UserBackend.php index 91e71a8..88119ee 100644 --- a/lib/Backend/UserBackend.php +++ b/lib/Backend/UserBackend.php @@ -278,6 +278,14 @@ final class UserBackend extends Backend $password, $user->password ); + if ($user->active == false) { + $this->logger->info( + "User account is inactive for user: $uid", + ["app" => $this->appName] + ); + return false; + } + if ($isCorrect !== true) { $this->logger->info( "Invalid password attempt for user: $uid", diff --git a/lib/Constant/DB.php b/lib/Constant/DB.php index 51f50f0..832cda5 100644 --- a/lib/Constant/DB.php +++ b/lib/Constant/DB.php @@ -45,6 +45,7 @@ final class DB const USER_GROUP_GID_COLUMN = "db.table.user_group.column.gid"; const USER_GROUP_UID_COLUMN = "db.table.user_group.column.uid"; + const USER_ACTIVE_COLUMN = "db.table.user.column.active"; const USER_AVATAR_COLUMN = "db.table.user.column.avatar"; const USER_EMAIL_COLUMN = "db.table.user.column.email"; const USER_HOME_COLUMN = "db.table.user.column.home"; diff --git a/lib/Model/User.php b/lib/Model/User.php index 65aed5b..90048f9 100644 --- a/lib/Model/User.php +++ b/lib/Model/User.php @@ -49,6 +49,10 @@ class User */ public $home; /** + * @var bool Is user account active. + */ + public $active; + /** * @var bool Can user change its avatar. */ public $avatar; diff --git a/lib/Query/QueryProvider.php b/lib/Query/QueryProvider.php index c1fdd52..742e784 100644 --- a/lib/Query/QueryProvider.php +++ b/lib/Query/QueryProvider.php @@ -65,6 +65,7 @@ class QueryProvider implements \ArrayAccess $gGID = $this->properties[DB::GROUP_GID_COLUMN]; $gName = $this->properties[DB::GROUP_NAME_COLUMN]; + $uActive = $this->properties[DB::USER_ACTIVE_COLUMN]; $uAvatar = $this->properties[DB::USER_AVATAR_COLUMN]; $uEmail = $this->properties[DB::USER_EMAIL_COLUMN]; $uHome = $this->properties[DB::USER_HOME_COLUMN]; @@ -90,6 +91,7 @@ class QueryProvider implements \ArrayAccess (empty($uName) ? "null" : $uName) . " AS name, " . (empty($uEmail) ? "null" : $uEmail) . " AS email, " . (empty($uHome) ? "null" : $uHome) . " AS home, " . + (empty($uActive) ? "true" : $uActive) . " AS active, " . (empty($uAvatar) ? "false" : $uAvatar) . " AS avatar"; $this->queries = [ diff --git a/templates/admin.php b/templates/admin.php index c0bc1ba..43d812e 100644 --- a/templates/admin.php +++ b/templates/admin.php @@ -147,6 +147,7 @@ function print_select_options( print_text_input($l, "db-table-user-column-home", "Home", $_['db.table.user.column.home']); print_text_input($l, "db-table-user-column-password", "Password", $_['db.table.user.column.password']); print_text_input($l, "db-table-user-column-name", "Display name", $_['db.table.user.column.name']); + print_text_input($l, "db-table-user-column-active", "Active", $_['db.table.user.column.active']); print_text_input($l, "db-table-user-column-avatar", "Can change avatar", $_['db.table.user.column.avatar']); ?> </fieldset> </div> |