summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/private/User/Manager.php18
-rw-r--r--lib/public/IUserManager.php9
2 files changed, 27 insertions, 0 deletions
diff --git a/lib/private/User/Manager.php b/lib/private/User/Manager.php
index 6220613cbb1..d482ee811f7 100644
--- a/lib/private/User/Manager.php
+++ b/lib/private/User/Manager.php
@@ -38,6 +38,7 @@ use OCP\IUser;
use OCP\IUserBackend;
use OCP\IUserManager;
use OCP\IConfig;
+use OCP\UserInterface;
/**
* Class Manager
@@ -321,10 +322,27 @@ class Manager extends PublicEmitter implements IUserManager {
return $user;
}
}
+
return false;
}
/**
+ * @param string $uid
+ * @param string $password
+ * @param UserInterface $backend
+ * @return IUser|null
+ */
+ public function createUserFromBackend($uid, $password, UserInterface $backend) {
+ $this->emit('\OC\User', 'preCreateUser', [$uid, $password]);
+ $backend->createUser($uid, $password);
+ $user = $this->getUserObject($uid, $backend);
+ if ($user instanceof IUser) {
+ $this->emit('\OC\User', 'postCreateUser', [$user, $password]);
+ }
+ return $user;
+ }
+
+ /**
* returns how many users per backend exist (if supported by backend)
*
* @param boolean $hasLoggedIn when true only users that have a lastLogin
diff --git a/lib/public/IUserManager.php b/lib/public/IUserManager.php
index 1f8c23dbedf..2287a24e9ec 100644
--- a/lib/public/IUserManager.php
+++ b/lib/public/IUserManager.php
@@ -130,6 +130,15 @@ interface IUserManager {
public function createUser($uid, $password);
/**
+ * @param string $uid
+ * @param string $password
+ * @param UserInterface $backend
+ * @return IUser|null
+ * @since 12.0.0
+ */
+ public function createUserFromBackend($uid, $password, UserInterface $backend);
+
+ /**
* returns how many users per backend exist (if supported by backend)
*
* @return array an array of backend class as key and count number as value