Name sync option
This commit is contained in:
12
CHANGELOG.md
12
CHANGELOG.md
@@ -8,12 +8,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
### Added
|
### Added
|
||||||
- Users can confirm passwords
|
- Users can confirm passwords
|
||||||
- Support Nextcloud password_policy
|
- Support Nextcloud password_policy
|
||||||
- Extend user/group search
|
|
||||||
- Support for Nextcloud 18
|
- Support for Nextcloud 18
|
||||||
- Do not include users which are disabled
|
- Name sync option
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Getting user display names backend
|
- Getting user display names backend
|
||||||
|
- Do not include users which are disabled
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Extend user/group search
|
||||||
|
|
||||||
## [4.3.0] - 2018-12-30
|
## [4.3.0] - 2018-12-30
|
||||||
### Added
|
### Added
|
||||||
@@ -30,9 +33,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
### Added
|
### Added
|
||||||
- Support for Nextcloud 15
|
- Support for Nextcloud 15
|
||||||
- Redmine, SHA-256, SHA-512 hash algorithms
|
- Redmine, SHA-256, SHA-512 hash algorithms
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Loading user list when display name is null
|
- Loading user list when display name is null
|
||||||
- Hide "password change form" when "Allow password change" not set
|
- Hide "password change form" when "Allow password change" not set
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Append salt only when checked. Not by default
|
- Append salt only when checked. Not by default
|
||||||
|
|
||||||
@@ -42,6 +47,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
- 'Prepend salt' toggle
|
- 'Prepend salt' toggle
|
||||||
- Drupal 7 hash algorithm
|
- Drupal 7 hash algorithm
|
||||||
- 'Case-insensitive username' option
|
- 'Case-insensitive username' option
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Error when 'Display name' not set
|
- Error when 'Display name' not set
|
||||||
- Encoding of iteration for 'Extended DES (Crypt)'
|
- Encoding of iteration for 'Extended DES (Crypt)'
|
||||||
@@ -62,8 +68,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|||||||
### Changed
|
### Changed
|
||||||
- Example SQL script in README file
|
- Example SQL script in README file
|
||||||
- Fixed misspelling
|
- Fixed misspelling
|
||||||
|
|
||||||
### Changed
|
|
||||||
- Support for Nextcloud 14 only
|
- Support for Nextcloud 14 only
|
||||||
- Group backend implementation
|
- Group backend implementation
|
||||||
- User backend implementation
|
- User backend implementation
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ Name | Description | Details
|
|||||||
**Reverse active column** | Reverse value of active column in user table. | Optional.<br/>Default: false.
|
**Reverse active column** | Reverse value of active column in user table. | Optional.<br/>Default: false.
|
||||||
**Use cache** | Use database query results cache. The cache can be cleared any time with the *Clear cache* button click. | Optional.<br/>Default: false.
|
**Use cache** | Use database query results cache. The cache can be cleared any time with the *Clear cache* button click. | Optional.<br/>Default: false.
|
||||||
**Hash algorithm** | How users passwords are stored in the database. See [Hash algorithms](#hash-algorithms). | Mandatory.
|
**Hash algorithm** | How users passwords are stored in the database. See [Hash algorithms](#hash-algorithms). | Mandatory.
|
||||||
|
**Name sync** | Sync display name with the Nextcloud.<br/>- *None* - Disables this feature. This is the default option.<br/>- *Synchronise only once* - Copy the display name to the Nextcloud preferences if its not set.<br/>- *Nextcloud always wins* - Always copy the display name to the database. This updates the user table.<br/>- *SQL always wins* - Always copy the display name to the Nextcloud preferences. | Optional.<br/>Default: *None*.<br/>Requires: user *Display name* column.
|
||||||
**Email sync** | Sync e-mail address with the Nextcloud.<br/>- *None* - Disables this feature. This is the default option.<br/>- *Synchronise only once* - Copy the e-mail address to the Nextcloud preferences if its not set.<br/>- *Nextcloud always wins* - Always copy the e-mail address to the database. This updates the user table.<br/>- *SQL always wins* - Always copy the e-mail address to the Nextcloud preferences. | Optional.<br/>Default: *None*.<br/>Requires: user *Email* column.
|
**Email sync** | Sync e-mail address with the Nextcloud.<br/>- *None* - Disables this feature. This is the default option.<br/>- *Synchronise only once* - Copy the e-mail address to the Nextcloud preferences if its not set.<br/>- *Nextcloud always wins* - Always copy the e-mail address to the database. This updates the user table.<br/>- *SQL always wins* - Always copy the e-mail address to the Nextcloud preferences. | Optional.<br/>Default: *None*.<br/>Requires: user *Email* column.
|
||||||
**Quota sync** | Sync user quota with the Nextcloud.<br/>- *None* - Disables this feature. This is the default option.<br/>- *Synchronise only once* - Copy the user quota to the Nextcloud preferences if its not set.<br/>- *Nextcloud always wins* - Always copy the user quota to the database. This updates the user table.<br/>- *SQL always wins* - Always copy the user quota to the Nextcloud preferences. | Optional.<br/>Default: *None*.<br/>Requires: user *Quota* column.
|
**Quota sync** | Sync user quota with the Nextcloud.<br/>- *None* - Disables this feature. This is the default option.<br/>- *Synchronise only once* - Copy the user quota to the Nextcloud preferences if its not set.<br/>- *Nextcloud always wins* - Always copy the user quota to the database. This updates the user table.<br/>- *SQL always wins* - Always copy the user quota to the Nextcloud preferences. | Optional.<br/>Default: *None*.<br/>Requires: user *Quota* column.
|
||||||
**Home mode** | User storage path.<br/>- *Default* - Let the Nextcloud manage this. The default option.<br/>- *Query* - Use location from the user table pointed by the *home* column.<br/>- *Static* - Use static location pointed by the *Home Location* option. | Optional<br/>Default: *Default*.
|
**Home mode** | User storage path.<br/>- *Default* - Let the Nextcloud manage this. The default option.<br/>- *Query* - Use location from the user table pointed by the *home* column.<br/>- *Static* - Use static location pointed by the *Home Location* option. | Optional<br/>Default: *Default*.
|
||||||
@@ -123,6 +124,7 @@ CREATE TABLE sql_user
|
|||||||
home TEXT NULL,
|
home TEXT NULL,
|
||||||
password TEXT NOT NULL,
|
password TEXT NOT NULL,
|
||||||
active TINYINT(1) NOT NULL DEFAULT '1',
|
active TINYINT(1) NOT NULL DEFAULT '1',
|
||||||
|
disabled TINYINT(1) NOT NULL DEFAULT '0',
|
||||||
provide_avatar BOOLEAN NOT NULL DEFAULT FALSE,
|
provide_avatar BOOLEAN NOT NULL DEFAULT FALSE,
|
||||||
salt TEXT NULL
|
salt TEXT NULL
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -99,6 +99,9 @@ class EmailSync implements IUserAction
|
|||||||
$this->config->setUserValue(
|
$this->config->setUserValue(
|
||||||
$user->uid, "settings", "email", $user->email
|
$user->uid, "settings", "email", $user->email
|
||||||
);
|
);
|
||||||
|
\OC::$server->getUserManager()->get($user->uid)->triggerChange(
|
||||||
|
'eMailAddress', $user->email, null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = true;
|
$result = true;
|
||||||
@@ -120,7 +123,9 @@ class EmailSync implements IUserAction
|
|||||||
$this->config->setUserValue(
|
$this->config->setUserValue(
|
||||||
$user->uid, "settings", "email", $user->email
|
$user->uid, "settings", "email", $user->email
|
||||||
);
|
);
|
||||||
\OC::$server->getUserManager()->get($user->uid)->triggerChange('eMailAddress', $user->email, null);
|
\OC::$server->getUserManager()->get($user->uid)->triggerChange(
|
||||||
|
'eMailAddress', $user->email, null
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = true;
|
$result = true;
|
||||||
|
|||||||
@@ -93,16 +93,45 @@ class NameSync implements IUserAction
|
|||||||
|
|
||||||
$result = false;
|
$result = false;
|
||||||
|
|
||||||
if (!empty($user->name) && $user->name !== $ncName) {
|
switch ($this->properties[Opt::NAME_SYNC]) {
|
||||||
$this->config->setUserValue(
|
case App::SYNC_INITIAL:
|
||||||
$user->uid, "settings", "displayName", $user->name
|
if (empty($ncName) && !empty($user->name)) {
|
||||||
);
|
$this->config->setUserValue(
|
||||||
\OC::$server->getUserManager()->get($user->uid)->triggerChange('displayName', $user->name, null);
|
$user->uid, "settings", "displayName", $user->name
|
||||||
|
);
|
||||||
|
\OC::$server->getUserManager()->get($user->uid)->triggerChange(
|
||||||
|
'displayName', $user->name, null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = true;
|
||||||
|
break;
|
||||||
|
case App::SYNC_FORCE_NC:
|
||||||
|
if (!empty($ncName) && $user->name !== $ncName) {
|
||||||
|
$user = $this->userRepository->findByUid($user->uid);
|
||||||
|
if (!($user instanceof User)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user->name = $ncName;
|
||||||
|
$result = $this->userRepository->save($user, UserRepository::DISPLAY_NAME_FIELD);
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case App::SYNC_FORCE_SQL:
|
||||||
|
if (!empty($user->name) && $user->name !== $ncName) {
|
||||||
|
$this->config->setUserValue(
|
||||||
|
$user->uid, "settings", "displayName", $user->name
|
||||||
|
);
|
||||||
|
\OC::$server->getUserManager()->get($user->uid)->triggerChange(
|
||||||
|
'displayName', $user->name, null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$result = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = true;
|
|
||||||
|
|
||||||
|
|
||||||
$this->logger->debug(
|
$this->logger->debug(
|
||||||
"Returning NameSync#doAction($user->uid): " . ($result ? "true"
|
"Returning NameSync#doAction($user->uid): " . ($result ? "true"
|
||||||
: "false"),
|
: "false"),
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ namespace OCA\UserSQL\Backend;
|
|||||||
use OC\User\Backend;
|
use OC\User\Backend;
|
||||||
use OCA\UserSQL\Action\EmailSync;
|
use OCA\UserSQL\Action\EmailSync;
|
||||||
use OCA\UserSQL\Action\IUserAction;
|
use OCA\UserSQL\Action\IUserAction;
|
||||||
use OCA\UserSQL\Action\QuotaSync;
|
|
||||||
use OCA\UserSQL\Action\NameSync;
|
use OCA\UserSQL\Action\NameSync;
|
||||||
|
use OCA\UserSQL\Action\QuotaSync;
|
||||||
use OCA\UserSQL\Cache;
|
use OCA\UserSQL\Cache;
|
||||||
use OCA\UserSQL\Constant\App;
|
use OCA\UserSQL\Constant\App;
|
||||||
use OCA\UserSQL\Constant\DB;
|
use OCA\UserSQL\Constant\DB;
|
||||||
@@ -152,7 +152,8 @@ final class UserBackend extends ABackend implements
|
|||||||
$this->userRepository
|
$this->userRepository
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (!empty($this->properties[DB::USER_NAME_COLUMN])
|
if (!empty($this->properties[Opt::NAME_SYNC])
|
||||||
|
&& !empty($this->properties[DB::USER_NAME_COLUMN])
|
||||||
) {
|
) {
|
||||||
$this->actions[] = new NameSync(
|
$this->actions[] = new NameSync(
|
||||||
$this->appName, $this->logger, $this->properties, $this->config,
|
$this->appName, $this->logger, $this->properties, $this->config,
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ final class Opt
|
|||||||
const HOME_LOCATION = "opt.home_location";
|
const HOME_LOCATION = "opt.home_location";
|
||||||
const HOME_MODE = "opt.home_mode";
|
const HOME_MODE = "opt.home_mode";
|
||||||
const NAME_CHANGE = "opt.name_change";
|
const NAME_CHANGE = "opt.name_change";
|
||||||
|
const NAME_SYNC = "opt.name_sync";
|
||||||
const PASSWORD_CHANGE = "opt.password_change";
|
const PASSWORD_CHANGE = "opt.password_change";
|
||||||
const PREPEND_SALT = "opt.prepend_salt";
|
const PREPEND_SALT = "opt.prepend_salt";
|
||||||
const PROVIDE_AVATAR = "opt.provide_avatar";
|
const PROVIDE_AVATAR = "opt.provide_avatar";
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ function print_select_options(
|
|||||||
</div>
|
</div>
|
||||||
<fieldset id="opt-crypto_params_content" class="inner-fieldset" style="display: none"></fieldset>
|
<fieldset id="opt-crypto_params_content" class="inner-fieldset" style="display: none"></fieldset>
|
||||||
<?php
|
<?php
|
||||||
|
print_select_options($l, "opt-name_sync", "Name sync", ["" => "None", "initial" => "Synchronise only once", "force_nc"=>"Nextcloud always wins", "force_sql"=>"SQL always wins"], $_["opt.name_sync"]);
|
||||||
print_select_options($l, "opt-email_sync", "Email sync", ["" => "None", "initial" => "Synchronise only once", "force_nc"=>"Nextcloud always wins", "force_sql"=>"SQL always wins"], $_["opt.email_sync"]);
|
print_select_options($l, "opt-email_sync", "Email sync", ["" => "None", "initial" => "Synchronise only once", "force_nc"=>"Nextcloud always wins", "force_sql"=>"SQL always wins"], $_["opt.email_sync"]);
|
||||||
print_select_options($l, "opt-quota_sync", "Quota sync", ["" => "None", "initial" => "Synchronise only once", "force_nc"=>"Nextcloud always wins", "force_sql"=>"SQL always wins"], $_["opt.quota_sync"]);
|
print_select_options($l, "opt-quota_sync", "Quota sync", ["" => "None", "initial" => "Synchronise only once", "force_nc"=>"Nextcloud always wins", "force_sql"=>"SQL always wins"], $_["opt.quota_sync"]);
|
||||||
print_select_options($l, "opt-home_mode", "Home mode", ["" => "Default", "query" => "Query", "static" => "Static"], $_["opt.home_mode"]);
|
print_select_options($l, "opt-home_mode", "Home mode", ["" => "Default", "query" => "Query", "static" => "Static"], $_["opt.home_mode"]);
|
||||||
|
|||||||
Reference in New Issue
Block a user