mirror of
https://github.com/netzbegruenung/user_saml.git
synced 2024-04-27 06:44:53 +02:00
Merge pull request #286 from nextcloud/fix-268
always create user in the SAML back-end and update the attributes
This commit is contained in:
commit
577f612267
|
@ -284,7 +284,10 @@ class SAMLController extends Controller {
|
|||
if (!($user instanceof IUser)) {
|
||||
throw new \InvalidArgumentException('User is not valid');
|
||||
}
|
||||
$user->updateLastLoginTimestamp();
|
||||
$firstLogin = $user->updateLastLoginTimestamp();
|
||||
if($firstLogin) {
|
||||
$this->userBackend->initializeHomeDir($user->getUID());
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->logger->logException($e, ['app' => $this->appName]);
|
||||
return new Http\RedirectResponse($this->urlGenerator->linkToRouteAbsolute('user_saml.SAML.notProvisioned'));
|
||||
|
|
|
@ -146,21 +146,30 @@ class UserBackend implements IApacheBackend, UserInterface, IUserBackend {
|
|||
}
|
||||
$qb->execute();
|
||||
|
||||
### Code taken from lib/private/User/Session.php - function prepareUserLogin() ###
|
||||
//trigger creation of user home and /files folder
|
||||
$userFolder = \OC::$server->getUserFolder($uid);
|
||||
try {
|
||||
// copy skeleton
|
||||
\OC_Util::copySkeleton($uid, $userFolder);
|
||||
} catch (NotPermittedException $ex) {
|
||||
// read only uses
|
||||
}
|
||||
// trigger any other initialization
|
||||
$user = $this->userManager->get($uid);
|
||||
\OC::$server->getEventDispatcher()->dispatch(IUser::class . '::firstLogin', new GenericEvent($user));
|
||||
$this->initializeHomeDir($uid);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $uid
|
||||
* @throws \OCP\Files\NotFoundException
|
||||
*/
|
||||
public function initializeHomeDir($uid) {
|
||||
### Code taken from lib/private/User/Session.php - function prepareUserLogin() ###
|
||||
//trigger creation of user home and /files folder
|
||||
$userFolder = \OC::$server->getUserFolder($uid);
|
||||
try {
|
||||
// copy skeleton
|
||||
\OC_Util::copySkeleton($uid, $userFolder);
|
||||
} catch (NotPermittedException $ex) {
|
||||
// read only uses
|
||||
}
|
||||
// trigger any other initialization
|
||||
$user = $this->userManager->get($uid);
|
||||
\OC::$server->getEventDispatcher()->dispatch(IUser::class . '::firstLogin', new GenericEvent($user));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if backend implements actions
|
||||
* @param int $actions bitwise-or'ed actions
|
||||
|
@ -227,7 +236,7 @@ class UserBackend implements IApacheBackend, UserInterface, IUserBackend {
|
|||
/**
|
||||
* Returns the user's home directory, if home directory mapping is set up.
|
||||
*
|
||||
* @param string $uid the username
|
||||
* @param string $uid the username
|
||||
* @return string
|
||||
*/
|
||||
public function getHome($uid) {
|
||||
|
|
Loading…
Reference in a new issue