Skip to content

Commit a312ba8

Browse files
committed
User active column
1 parent b00f611 commit a312ba8

8 files changed

Lines changed: 21 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- User active column
810

911
## [4.0.0-rc1]
1012
### Added

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Name | Description | Details
6767
**Home** | Home path column. | Mandatory for `Query` *Home sync* option.
6868
**Password** | Password hash column. | Mandatory for user backend.
6969
**Display name** | Display name column. | Optional.
70+
**Active** | Flag indicating if user can log in. | Optional.<br/>Default: true.
7071
**Can change avatar** | Flag indicating if user can change its avatar. | Optional.<br/>Default: false.
7172

7273
#### Group table
@@ -161,6 +162,7 @@ User table: jhi_users
161162
Username column: login
162163
Password column: password_hash
163164
Email column: email
165+
Active column: activated
164166
165167
Hashing algorithm: Unix (Crypt)
166168
```

js/settings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ user_sql.adminSettingsUI = function () {
7575
);
7676

7777
autocomplete(
78-
"#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",
78+
"#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",
7979
"/apps/user_sql/settings/autocomplete/table/user"
8080
);
8181

lib/Backend/UserBackend.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,14 @@ public function checkPassword($uid, $password)
278278
$password, $user->password
279279
);
280280

281+
if ($user->active == false) {
282+
$this->logger->info(
283+
"User account is inactive for user: $uid",
284+
["app" => $this->appName]
285+
);
286+
return false;
287+
}
288+
281289
if ($isCorrect !== true) {
282290
$this->logger->info(
283291
"Invalid password attempt for user: $uid",

lib/Constant/DB.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ final class DB
4545
const USER_GROUP_GID_COLUMN = "db.table.user_group.column.gid";
4646
const USER_GROUP_UID_COLUMN = "db.table.user_group.column.uid";
4747

48+
const USER_ACTIVE_COLUMN = "db.table.user.column.active";
4849
const USER_AVATAR_COLUMN = "db.table.user.column.avatar";
4950
const USER_EMAIL_COLUMN = "db.table.user.column.email";
5051
const USER_HOME_COLUMN = "db.table.user.column.home";

lib/Model/User.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class User
4848
* @var string The user's home location.
4949
*/
5050
public $home;
51+
/**
52+
* @var bool Is user account active.
53+
*/
54+
public $active;
5155
/**
5256
* @var bool Can user change its avatar.
5357
*/

lib/Query/QueryProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ private function loadQueries()
6565
$gGID = $this->properties[DB::GROUP_GID_COLUMN];
6666
$gName = $this->properties[DB::GROUP_NAME_COLUMN];
6767

68+
$uActive = $this->properties[DB::USER_ACTIVE_COLUMN];
6869
$uAvatar = $this->properties[DB::USER_AVATAR_COLUMN];
6970
$uEmail = $this->properties[DB::USER_EMAIL_COLUMN];
7071
$uHome = $this->properties[DB::USER_HOME_COLUMN];
@@ -90,6 +91,7 @@ private function loadQueries()
9091
(empty($uName) ? "null" : $uName) . " AS name, " .
9192
(empty($uEmail) ? "null" : $uEmail) . " AS email, " .
9293
(empty($uHome) ? "null" : $uHome) . " AS home, " .
94+
(empty($uActive) ? "true" : $uActive) . " AS active, " .
9395
(empty($uAvatar) ? "false" : $uAvatar) . " AS avatar";
9496

9597
$this->queries = [

templates/admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ function print_select_options(
147147
print_text_input($l, "db-table-user-column-home", "Home", $_['db.table.user.column.home']);
148148
print_text_input($l, "db-table-user-column-password", "Password", $_['db.table.user.column.password']);
149149
print_text_input($l, "db-table-user-column-name", "Display name", $_['db.table.user.column.name']);
150+
print_text_input($l, "db-table-user-column-active", "Active", $_['db.table.user.column.active']);
150151
print_text_input($l, "db-table-user-column-avatar", "Can change avatar", $_['db.table.user.column.avatar']); ?>
151152
</fieldset>
152153
</div>

0 commit comments

Comments
 (0)