diff --git a/.travis.yml b/.travis.yml
index 32185267..0a3c744e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,7 +9,7 @@ env:
- APP_NAME=guests
- DB=sqlite
matrix:
- - CORE_BRANCH=stable17
+ - CORE_BRANCH=master
branches:
only:
diff --git a/appinfo/info.xml b/appinfo/info.xml
index a10fa803..a9bbb5c9 100755
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -22,7 +22,7 @@ Guests users can only access files shared to them and can't create any files out
https://raw.githubusercontent.com/nextcloud/guests/master/screenshots/settings.png
https://raw.githubusercontent.com/nextcloud/guests/master/screenshots/dropdown.png
-
+
OCA\Guests\Command\ListCommand
diff --git a/lib/GuestManager.php b/lib/GuestManager.php
index dfd80bc1..85d251bc 100644
--- a/lib/GuestManager.php
+++ b/lib/GuestManager.php
@@ -32,6 +32,7 @@
use OCP\IUserBackend;
use OCP\IUserManager;
use OCP\IUserSession;
+use OCP\Security\Events\GenerateSecurePasswordEvent;
use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;
use OCP\Share\IManager;
@@ -97,11 +98,11 @@ public function isGuest($user = null) {
}
public function createGuest(IUser $createdBy, $userId, $email, $displayName = '', $language = '') {
- $passwordEvent = new Event(null, ['password' => $this->secureRandom->generate(20)]);
- $this->eventDispatcher->dispatch('OCP\PasswordPolicy::generate', $passwordEvent);
+ $passwordEvent = new GenerateSecurePasswordEvent();
+ $this->eventDispatcher->dispatchTyped($passwordEvent);
$this->userBackend->createUser(
$userId,
- $passwordEvent->getArgument('password')
+ $passwordEvent->getPassword() ?? $this->secureRandom->generate(20)
);
$this->config->setUserValue($userId, 'settings', 'email', $email);
diff --git a/lib/UserBackend.php b/lib/UserBackend.php
index dcb9ca12..7fad5dbe 100644
--- a/lib/UserBackend.php
+++ b/lib/UserBackend.php
@@ -23,7 +23,9 @@
namespace OCA\Guests;
use OC\Cache\CappedMemoryCache;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IDBConnection;
+use OCP\Security\Events\ValidatePasswordPolicyEvent;
use OCP\Security\IHasher;
use OCP\User\Backend\ABackend;
use OCP\User\Backend\ICheckPasswordBackend;
@@ -32,8 +34,6 @@
use OCP\User\Backend\IGetHomeBackend;
use OCP\User\Backend\ISetDisplayNameBackend;
use OCP\User\Backend\ISetPasswordBackend;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
/**
* Class for user management in a SQL Database (e.g. MySQL, SQLite)
@@ -54,7 +54,7 @@ class UserBackend extends ABackend
private $allowListing = true;
public function __construct(
- EventDispatcherInterface $eventDispatcher,
+ IEventDispatcher $eventDispatcher,
IDBConnection $connection,
Config $config,
IHasher $hasher
@@ -82,8 +82,7 @@ public function setAllowListing(bool $allow) {
*/
public function createUser(string $uid, string $password): bool {
if (!$this->userExists($uid)) {
- $event = new GenericEvent($password);
- $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event);
+ $this->eventDispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password));
$qb = $this->dbConn->getQueryBuilder();
$qb->insert('guests_users')
@@ -137,8 +136,7 @@ public function deleteUser($uid) {
*/
public function setPassword(string $uid, string $password): bool {
if ($this->userExists($uid)) {
- $event = new GenericEvent($password);
- $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event);
+ $this->eventDispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password));
$hashedPassword = $this->hasher->hash($password);
diff --git a/package-lock.json b/package-lock.json
index ed359d26..e0ffb10f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -827,6 +827,12 @@
"to-fast-properties": "^2.0.0"
}
},
+ "@nextcloud/browserslist-config": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/@nextcloud/browserslist-config/-/browserslist-config-1.0.0.tgz",
+ "integrity": "sha512-f+sKpdLZXkODV+OY39K1M+Spmd4RgxmtEXmNn4Bviv4R7uBFHXuw+JX9ZdfDeOryfHjJ/TRQxQEp0GMpBwZFUw==",
+ "dev": true
+ },
"@types/events": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/@types/events/-/events-3.0.0.tgz",
diff --git a/package.json b/package.json
index aaadd661..e7a4bd98 100644
--- a/package.json
+++ b/package.json
@@ -30,6 +30,7 @@
"devDependencies": {
"@babel/core": "^7.7.4",
"@babel/preset-env": "^7.7.4",
+ "@nextcloud/browserslist-config": "^1.0.0",
"babel-loader": "^8.0.6",
"browserslist-config-nextcloud": "0.1.0",
"css-loader": "^3.2.0",
diff --git a/tests/unit/UserBackendTest.php b/tests/unit/UserBackendTest.php
index 095891ca..603a657f 100644
--- a/tests/unit/UserBackendTest.php
+++ b/tests/unit/UserBackendTest.php
@@ -24,8 +24,8 @@
use OCA\Guests\Config;
use OCA\Guests\UserBackend;
+use OCP\EventDispatcher\IEventDispatcher;
use PHPUnit\Framework\MockObject\MockObject;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Test\TestCase;
/**
@@ -52,7 +52,7 @@ protected function setUp() {
$this->config = $this->createMock(Config::class);
$this->backend = new UserBackend(
- $this->createMock(EventDispatcherInterface::class),
+ $this->createMock(IEventDispatcher::class),
\OC::$server->getDatabaseConnection(),
$this->config,
\OC::$server->getHasher()