Skip to content

Commit b1b1ffb

Browse files
committed
Merge branch 'release/v4.0.0-rc2'
2 parents 1028e5f + 5a4d283 commit b1b1ffb

10 files changed

Lines changed: 40 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
44
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

7+
## [v4.0.0-rc2]
8+
### Added
9+
- User active column
10+
11+
### Changed
12+
- Fixed "Use of undefined constant" error for Argon2 Crypt with PHP below 7.2.
13+
714
## [4.0.0-rc1]
815
### Added
916
- New hashing algorithms: Argon2 Crypt (PHP 7.2 and above), Blowfish Crypt, Courier base64-encoded MD5, Courier base64-encoded SHA1,
@@ -58,5 +65,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5865
### Changed
5966
- Supported version of ownCloud, Nextcloud: ownCloud 10, Nextcloud 12
6067

68+
[v4.0.0-rc2]: https://github.com/nextcloud/user_sql/compare/v4.0.0-rc1...v4.0.0-rc2
6169
[4.0.0-rc1]: https://github.com/nextcloud/user_sql/compare/v3.1.0...v4.0.0-rc1
6270
[3.1.0]: https://github.com/nextcloud/user_sql/compare/v2.4.0...v3.1.0

README.md

Lines changed: 3 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
@@ -112,6 +113,7 @@ CREATE TABLE sql_users
112113
email TEXT NULL,
113114
home TEXT NULL,
114115
password TEXT NOT NULL,
116+
active TINYINT(1) NOT NULL DEFAULT '1',
115117
can_change_avatar BOOLEAN NOT NULL DEFAULT FALSE,
116118
CONSTRAINT users_username_uindex UNIQUE (username)
117119
);
@@ -161,6 +163,7 @@ User table: jhi_users
161163
Username column: login
162164
Password column: password_hash
163165
Email column: email
166+
Active column: activated
164167
165168
Hashing algorithm: Unix (Crypt)
166169
```

appinfo/info.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
Retrieve the users and groups info. Allow the users to change their passwords.
99
Sync the users' email addresses with the addresses stored by Nextcloud.
1010
</description>
11-
<version>4.0.0-rc1</version>
11+
<version>4.0.0-rc2</version>
1212
<licence>agpl</licence>
1313
<author>Andreas Böhler &lt;dev (at) aboehler (dot) at&gt;</author>
1414
<author>Marcin Łojewski &lt;dev@mlojewski.me&gt;</author>

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/Crypto/CryptArgon2.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,22 @@ class CryptArgon2 extends AbstractAlgorithm
5454
* @param int $threads Number of threads to use for computing.
5555
*/
5656
public function __construct(
57-
IL10N $localization,
58-
$memoryCost = PASSWORD_ARGON2_DEFAULT_MEMORY_COST,
59-
$timeCost = PASSWORD_ARGON2_DEFAULT_TIME_COST,
60-
$threads = PASSWORD_ARGON2_DEFAULT_THREADS
57+
IL10N $localization, $memoryCost = -1, $timeCost = -1, $threads = -1
6158
) {
6259
if (version_compare(PHP_VERSION, "7.2.0") === -1) {
6360
throw new \RuntimeException(
6461
"PASSWORD_ARGON2I requires PHP 7.2.0 or above."
6562
);
63+
} else {
64+
if ($memoryCost === -1) {
65+
$memoryCost = PASSWORD_ARGON2_DEFAULT_MEMORY_COST;
66+
}
67+
if ($timeCost === -1) {
68+
$timeCost = PASSWORD_ARGON2_DEFAULT_TIME_COST;
69+
}
70+
if ($threads === -1) {
71+
$threads = PASSWORD_ARGON2_DEFAULT_THREADS;
72+
}
6673
}
6774

6875
parent::__construct($localization);

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)