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:
Björn Schiessle 2019-01-24 14:58:11 +01:00 committed by GitHub
commit 577f612267
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 14 deletions

View file

@ -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'));

View file

@ -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) {