Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/Controller/Id4meController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;

use OCP\ServerVersion;
use OCP\Util;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -71,6 +72,7 @@ public function __construct(
private ID4MeService $id4MeService,
private LoggerInterface $logger,
private ICrypto $crypto,
private ServerVersion $serverVersion,
) {
parent::__construct($request, $config, $l10n);

Expand Down Expand Up @@ -322,6 +324,6 @@ public function code(string $state = '', string $code = '', string $scope = '')
// Set last password confirm to the future as we don't have passwords to confirm against with SSO
$this->session->set('last-password-confirm', strtotime('+4 year', time()));

return new RedirectResponse(\OC_Util::getDefaultPageUrl());
return new RedirectResponse($this->serverVersion->getMajorVersion() >= 32 ? $this->urlGenerator->linkToDefaultPageUrl() : \OC_Util::getDefaultPageUrl());
}
}
4 changes: 3 additions & 1 deletion lib/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
use OCP\IUserSession;
use OCP\Security\ICrypto;
use OCP\Security\ISecureRandom;
use OCP\ServerVersion;
use OCP\Session\Exceptions\SessionNotAvailableException;
use OCP\User\Events\BeforeUserLoggedInEvent;
use OCP\User\Events\UserCreatedEvent;
Expand Down Expand Up @@ -99,6 +100,7 @@ public function __construct(
private ICrypto $crypto,
private TokenService $tokenService,
private OidcService $oidcService,
private ServerVersion $serverVersion,
) {
parent::__construct($request, $config, $l10n);
}
Expand Down Expand Up @@ -696,7 +698,7 @@ public function code(string $state = '', string $code = '', string $scope = '',
return $this->getRedirectResponse($redirectUrl);
}

return new RedirectResponse(\OC_Util::getDefaultPageUrl());
return new RedirectResponse($this->serverVersion->getMajorVersion() >= 32 ? $this->urlGenerator->linkToDefaultPageUrl() : \OC_Util::getDefaultPageUrl());
}

/**
Expand Down
12 changes: 8 additions & 4 deletions lib/User/Backend.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
use OCP\DB\Exception;
use OCP\EventDispatcher\GenericEvent;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
use OCP\Files\ISetupManager;
use OCP\Files\NotFoundException;
use OCP\Files\NotPermittedException;
use OCP\IConfig;
Expand All @@ -35,11 +37,13 @@
use OCP\IUser;
use OCP\IUserManager;
use OCP\Server;
use OCP\ServerVersion;
use OCP\User\Backend\ABackend;
use OCP\User\Backend\ICountUsersBackend;
use OCP\User\Backend\ICustomLogout;
use OCP\User\Backend\IGetDisplayNameBackend;
use OCP\User\Backend\IPasswordConfirmationBackend;
use OCP\User\Events\UserFirstTimeLoggedInEvent;
use Psr\Log\LoggerInterface;
use Throwable;

Expand All @@ -63,6 +67,7 @@ public function __construct(
private ProvisioningService $provisioningService,
private LdapService $ldapService,
private IUserManager $userManager,
private ServerVersion $serverVersion,
) {
}

Expand Down Expand Up @@ -391,9 +396,9 @@ private function checkFirstLogin(string $userId): bool {

$firstLogin = $user->getLastLogin() === 0;
if ($firstLogin) {
\OC_Util::setupFS($userId);
$this->serverVersion->getMajorVersion() >= 34 ? Server::get(ISetupManager::class)->setupForUser($user) : \OC_Util::setupFS($userId);
// trigger creation of user home and /files folder
$userFolder = \OC::$server->getUserFolder($userId);
$userFolder = Server::get(IRootFolder::class)->getUserFolder($userId);
try {
// copy skeleton
\OC_Util::copySkeleton($userId, $userFolder);
Expand All @@ -403,8 +408,7 @@ private function checkFirstLogin(string $userId): bool {

// trigger any other initialization
$this->eventDispatcher->dispatch(IUser::class . '::firstLogin', new GenericEvent($user));
// TODO add this when user_oidc min NC version is >= 28
// $this->eventDispatcher->dispatchTyped(new UserFirstTimeLoggedInEvent($user));
$this->eventDispatcher->dispatchTyped(new UserFirstTimeLoggedInEvent($user));
}
$user->updateLastLoginTimestamp();
return $firstLogin;
Expand Down
4 changes: 4 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<referencedClass name="Symfony\Component\Console\Question\ConfirmationQuestion" />
<referencedClass name="OC\Accounts\AccountManager" />
<referencedClass name="OCA\OIDCIdentityProvider\AppInfo\Application" />
<referencedClass name="OCP\ServerVersion" />
<referencedClass name="OCP\Files\ISetupManager" />
<referencedClass name="OCP\User\Events\UserFirstTimeLoggedInEvent" />
</errorLevel>
</UndefinedClass>
<UndefinedDocblockClass>
Expand All @@ -59,6 +62,7 @@
<referencedClass name="OCA\User_LDAP\User_Proxy" />
<referencedClass name="OCA\User_LDAP\User\DeletedUsersIndex" />
<referencedClass name="Doctrine\DBAL\Schema\SchemaException" />
<referencedClass name="OCP\Files\ISetupManager" />
</errorLevel>
</UndefinedDocblockClass>
</issueHandlers>
Expand Down
Loading