Skip to content

Commit 1283fd6

Browse files
committed
issue#95 - Do not include users which are disabled
1 parent ce09d8e commit 1283fd6

5 files changed

Lines changed: 15 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
- Support Nextcloud password_policy
1111
- Extend user/group search
1212
- Support for Nextcloud 18
13+
- Do not include users which are disabled
1314

1415
### Fixed
1516
- Getting user display names backend

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Name | Description | Details
7373
**Password** | Password hash column. | Mandatory for user backend.
7474
**Display name** | Display name column. | Optional.
7575
**Active** | Flag indicating if user can log in. | Optional.<br/>Default: true.
76+
**Disabled** | Flag indicating if user should not be visible (not included in searches). | Optional.<br/>Default: false.
7677
**Provide avatar** | Flag indicating if user can change its avatar. | Optional.<br/>Default: false.
7778
**Salt** | Salt which is appended to password when checking or changing the password. | Optional.
7879
**Append salt** | Append a salt to the password. | Optional.<br/>Default: false.

lib/Constant/DB.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ final class DB
4747

4848
const USER_ACTIVE_COLUMN = "db.table.user.column.active";
4949
const USER_AVATAR_COLUMN = "db.table.user.column.avatar";
50+
const USER_DISABLED_COLUMN = "db.table.user.column.disabled";
5051
const USER_EMAIL_COLUMN = "db.table.user.column.email";
5152
const USER_HOME_COLUMN = "db.table.user.column.home";
5253
const USER_NAME_COLUMN = "db.table.user.column.name";

lib/Query/QueryProvider.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ private function loadQueries()
6868

6969
$uActive = $this->properties[DB::USER_ACTIVE_COLUMN];
7070
$uAvatar = $this->properties[DB::USER_AVATAR_COLUMN];
71+
$uDisabled = $this->properties[DB::USER_DISABLED_COLUMN];
7172
$uEmail = $this->properties[DB::USER_EMAIL_COLUMN];
7273
$uHome = $this->properties[DB::USER_HOME_COLUMN];
7374
$uName = $this->properties[DB::USER_NAME_COLUMN];
@@ -121,7 +122,8 @@ private function loadQueries()
121122
Query::COUNT_USERS =>
122123
"SELECT COUNT(u.$uUID) AS count " .
123124
"FROM $user u " .
124-
"WHERE u.$uUID LIKE :$searchParam",
125+
"WHERE u.$uUID LIKE :$searchParam " .
126+
(empty($uDisabled) ? "" : "AND NOT u.$uDisabled"),
125127

126128
Query::FIND_GROUP =>
127129
"SELECT $groupColumns " .
@@ -146,12 +148,14 @@ private function loadQueries()
146148
Query::FIND_USER =>
147149
"SELECT $userColumns, u.$uPassword AS password " .
148150
"FROM $user u " .
149-
"WHERE u.$uUID = :$uidParam",
151+
"WHERE u.$uUID = :$uidParam " .
152+
(empty($uDisabled) ? "" : "AND NOT u.$uDisabled"),
150153

151154
Query::FIND_USER_CASE_INSENSITIVE =>
152155
"SELECT $userColumns, u.$uPassword AS password " .
153156
"FROM $user u " .
154-
"WHERE lower(u.$uUID) = lower(:$uidParam)",
157+
"WHERE lower(u.$uUID) = lower(:$uidParam) " .
158+
(empty($uDisabled) ? "" : "AND NOT u.$uDisabled"),
155159

156160
Query::FIND_USER_GROUPS =>
157161
"SELECT $groupColumns " .
@@ -163,9 +167,12 @@ private function loadQueries()
163167
Query::FIND_USERS =>
164168
"SELECT $userColumns " .
165169
"FROM $user u " .
166-
"WHERE u.$uUID LIKE :$searchParam " .
170+
"WHERE (" .
171+
"u.$uUID LIKE :$searchParam " .
167172
(empty($uName) ? "" : "OR u.$uName LIKE :$searchParam ") .
168173
(empty($uEmail) ? "" : "OR u.$uEmail LIKE :$searchParam ") .
174+
")" .
175+
(empty($uDisabled) ? "" : "AND NOT u.$uDisabled ") .
169176
"ORDER BY u.$uUID",
170177

171178
Query::UPDATE_DISPLAY_NAME =>

templates/admin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ function print_select_options(
158158
print_text_input($l, "db-table-user-column-password", "Password", $_["db.table.user.column.password"]);
159159
print_text_input($l, "db-table-user-column-name", "Display name", $_["db.table.user.column.name"]);
160160
print_text_input($l, "db-table-user-column-active", "Active", $_["db.table.user.column.active"]);
161+
print_text_input($l, "db-table-user-column-disabled", "Disabled", $_["db.table.user.column.disabled"]);
161162
print_text_input($l, "db-table-user-column-avatar", "Provide avatar", $_["db.table.user.column.avatar"]);
162163
print_text_input($l, "db-table-user-column-salt", "Salt", $_["db.table.user.column.salt"]); ?>
163164
<div class="inner-fieldset">

0 commit comments

Comments
 (0)