summaryrefslogtreecommitdiffstats
path: root/lib/private/user/database.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/user/database.php')
-rw-r--r--lib/private/user/database.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/private/user/database.php b/lib/private/user/database.php
index fd273055ae1..4622be1657d 100644
--- a/lib/private/user/database.php
+++ b/lib/private/user/database.php
@@ -49,6 +49,8 @@
*/
use OC\Cache\CappedMemoryCache;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+use Symfony\Component\EventDispatcher\GenericEvent;
/**
* Class for user management in a SQL Database (e.g. MySQL, SQLite)
@@ -59,9 +61,12 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend {
/**
* OC_User_Database constructor.
+ *
+ * @param EventDispatcher $eventDispatcher
*/
- public function __construct() {
+ public function __construct(EventDispatcher $eventDispatcher = null) {
$this->cache = new CappedMemoryCache();
+ $this->eventDispatcher = $eventDispatcher ? $eventDispatcher : \OC::$server->getEventDispatcher();
}
/**
@@ -113,6 +118,8 @@ class OC_User_Database extends OC_User_Backend implements \OCP\IUserBackend {
*/
public function setPassword($uid, $password) {
if ($this->userExists($uid)) {
+ $event = new GenericEvent($password);
+ $this->eventDispatcher->dispatch('OCP\PasswordPolicy::validate', $event);
$query = OC_DB::prepare('UPDATE `*PREFIX*users` SET `password` = ? WHERE `uid` = ?');
$result = $query->execute(array(\OC::$server->getHasher()->hash($password), $uid));