Allow to create a user for a specific backend

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2017-04-26 15:07:11 +02:00
parent 5b5c3a1773
commit 9e6ac3de70
No known key found for this signature in database
GPG Key ID: E166FD8976B3BAC8
2 changed files with 27 additions and 0 deletions

View File

@ -38,6 +38,7 @@ use OCP\IUser;
use OCP\IUserBackend; use OCP\IUserBackend;
use OCP\IUserManager; use OCP\IUserManager;
use OCP\IConfig; use OCP\IConfig;
use OCP\UserInterface;
/** /**
* Class Manager * Class Manager
@ -321,9 +322,26 @@ class Manager extends PublicEmitter implements IUserManager {
return $user; return $user;
} }
} }
return false; 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) * returns how many users per backend exist (if supported by backend)
* *

View File

@ -129,6 +129,15 @@ interface IUserManager {
*/ */
public function createUser($uid, $password); 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) * returns how many users per backend exist (if supported by backend)
* *