issue#95 - Do not include users which are disabled

This commit is contained in:
Marcin Łojewski
2019-10-08 19:44:23 +02:00
parent ce09d8e5e1
commit 1283fd68fc
5 changed files with 15 additions and 4 deletions

View File

@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Support Nextcloud password_policy - Support Nextcloud password_policy
- Extend user/group search - Extend user/group search
- Support for Nextcloud 18 - Support for Nextcloud 18
- Do not include users which are disabled
### Fixed ### Fixed
- Getting user display names backend - Getting user display names backend

View File

@@ -73,6 +73,7 @@ Name | Description | Details
**Password** | Password hash column. | Mandatory for user backend. **Password** | Password hash column. | Mandatory for user backend.
**Display name** | Display name column. | Optional. **Display name** | Display name column. | Optional.
**Active** | Flag indicating if user can log in. | Optional.<br/>Default: true. **Active** | Flag indicating if user can log in. | Optional.<br/>Default: true.
**Disabled** | Flag indicating if user should not be visible (not included in searches). | Optional.<br/>Default: false.
**Provide avatar** | Flag indicating if user can change its avatar. | Optional.<br/>Default: false. **Provide avatar** | Flag indicating if user can change its avatar. | Optional.<br/>Default: false.
**Salt** | Salt which is appended to password when checking or changing the password. | Optional. **Salt** | Salt which is appended to password when checking or changing the password. | Optional.
**Append salt** | Append a salt to the password. | Optional.<br/>Default: false. **Append salt** | Append a salt to the password. | Optional.<br/>Default: false.

View File

@@ -47,6 +47,7 @@ final class DB
const USER_ACTIVE_COLUMN = "db.table.user.column.active"; const USER_ACTIVE_COLUMN = "db.table.user.column.active";
const USER_AVATAR_COLUMN = "db.table.user.column.avatar"; const USER_AVATAR_COLUMN = "db.table.user.column.avatar";
const USER_DISABLED_COLUMN = "db.table.user.column.disabled";
const USER_EMAIL_COLUMN = "db.table.user.column.email"; const USER_EMAIL_COLUMN = "db.table.user.column.email";
const USER_HOME_COLUMN = "db.table.user.column.home"; const USER_HOME_COLUMN = "db.table.user.column.home";
const USER_NAME_COLUMN = "db.table.user.column.name"; const USER_NAME_COLUMN = "db.table.user.column.name";

View File

@@ -68,6 +68,7 @@ class QueryProvider implements \ArrayAccess
$uActive = $this->properties[DB::USER_ACTIVE_COLUMN]; $uActive = $this->properties[DB::USER_ACTIVE_COLUMN];
$uAvatar = $this->properties[DB::USER_AVATAR_COLUMN]; $uAvatar = $this->properties[DB::USER_AVATAR_COLUMN];
$uDisabled = $this->properties[DB::USER_DISABLED_COLUMN];
$uEmail = $this->properties[DB::USER_EMAIL_COLUMN]; $uEmail = $this->properties[DB::USER_EMAIL_COLUMN];
$uHome = $this->properties[DB::USER_HOME_COLUMN]; $uHome = $this->properties[DB::USER_HOME_COLUMN];
$uName = $this->properties[DB::USER_NAME_COLUMN]; $uName = $this->properties[DB::USER_NAME_COLUMN];
@@ -121,7 +122,8 @@ class QueryProvider implements \ArrayAccess
Query::COUNT_USERS => Query::COUNT_USERS =>
"SELECT COUNT(u.$uUID) AS count " . "SELECT COUNT(u.$uUID) AS count " .
"FROM $user u " . "FROM $user u " .
"WHERE u.$uUID LIKE :$searchParam", "WHERE u.$uUID LIKE :$searchParam " .
(empty($uDisabled) ? "" : "AND NOT u.$uDisabled"),
Query::FIND_GROUP => Query::FIND_GROUP =>
"SELECT $groupColumns " . "SELECT $groupColumns " .
@@ -146,12 +148,14 @@ class QueryProvider implements \ArrayAccess
Query::FIND_USER => Query::FIND_USER =>
"SELECT $userColumns, u.$uPassword AS password " . "SELECT $userColumns, u.$uPassword AS password " .
"FROM $user u " . "FROM $user u " .
"WHERE u.$uUID = :$uidParam", "WHERE u.$uUID = :$uidParam " .
(empty($uDisabled) ? "" : "AND NOT u.$uDisabled"),
Query::FIND_USER_CASE_INSENSITIVE => Query::FIND_USER_CASE_INSENSITIVE =>
"SELECT $userColumns, u.$uPassword AS password " . "SELECT $userColumns, u.$uPassword AS password " .
"FROM $user u " . "FROM $user u " .
"WHERE lower(u.$uUID) = lower(:$uidParam)", "WHERE lower(u.$uUID) = lower(:$uidParam) " .
(empty($uDisabled) ? "" : "AND NOT u.$uDisabled"),
Query::FIND_USER_GROUPS => Query::FIND_USER_GROUPS =>
"SELECT $groupColumns " . "SELECT $groupColumns " .
@@ -163,9 +167,12 @@ class QueryProvider implements \ArrayAccess
Query::FIND_USERS => Query::FIND_USERS =>
"SELECT $userColumns " . "SELECT $userColumns " .
"FROM $user u " . "FROM $user u " .
"WHERE u.$uUID LIKE :$searchParam " . "WHERE (" .
"u.$uUID LIKE :$searchParam " .
(empty($uName) ? "" : "OR u.$uName LIKE :$searchParam ") . (empty($uName) ? "" : "OR u.$uName LIKE :$searchParam ") .
(empty($uEmail) ? "" : "OR u.$uEmail LIKE :$searchParam ") . (empty($uEmail) ? "" : "OR u.$uEmail LIKE :$searchParam ") .
")" .
(empty($uDisabled) ? "" : "AND NOT u.$uDisabled ") .
"ORDER BY u.$uUID", "ORDER BY u.$uUID",
Query::UPDATE_DISPLAY_NAME => Query::UPDATE_DISPLAY_NAME =>

View File

@@ -158,6 +158,7 @@ function print_select_options(
print_text_input($l, "db-table-user-column-password", "Password", $_["db.table.user.column.password"]); 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-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-active", "Active", $_["db.table.user.column.active"]);
print_text_input($l, "db-table-user-column-disabled", "Disabled", $_["db.table.user.column.disabled"]);
print_text_input($l, "db-table-user-column-avatar", "Provide avatar", $_["db.table.user.column.avatar"]); print_text_input($l, "db-table-user-column-avatar", "Provide avatar", $_["db.table.user.column.avatar"]);
print_text_input($l, "db-table-user-column-salt", "Salt", $_["db.table.user.column.salt"]); ?> print_text_input($l, "db-table-user-column-salt", "Salt", $_["db.table.user.column.salt"]); ?>
<div class="inner-fieldset"> <div class="inner-fieldset">