summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-04-26 15:07:11 +0200
committerJoas Schilling <coding@schilljs.com>2017-04-26 15:07:11 +0200
commit9e6ac3de700ebf51e3677e752db4928afacbf7e6 (patch)
tree036d048ceb0f2172e34f49180818a67f2a1e4f83
parent5b5c3a1773dab4960d41aafc4150859a308311b7 (diff)
downloadnextcloud-server-9e6ac3de700ebf51e3677e752db4928afacbf7e6.tar.gz
nextcloud-server-9e6ac3de700ebf51e3677e752db4928afacbf7e6.zip
Allow to create a user for a specific backend
Signed-off-by: Joas Schilling <coding@schilljs.com>
-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