2626use OCP \DB \Exception ;
2727use OCP \EventDispatcher \GenericEvent ;
2828use OCP \EventDispatcher \IEventDispatcher ;
29+ use OCP \Files \IRootFolder ;
30+ use OCP \Files \ISetupManager ;
2931use OCP \Files \NotFoundException ;
3032use OCP \Files \NotPermittedException ;
3133use OCP \IConfig ;
3537use OCP \IUser ;
3638use OCP \IUserManager ;
3739use OCP \Server ;
40+ use OCP \ServerVersion ;
3841use OCP \User \Backend \ABackend ;
3942use OCP \User \Backend \ICountUsersBackend ;
4043use OCP \User \Backend \ICustomLogout ;
4144use OCP \User \Backend \IGetDisplayNameBackend ;
4245use OCP \User \Backend \IPasswordConfirmationBackend ;
46+ use OCP \User \Events \UserFirstTimeLoggedInEvent ;
4347use Psr \Log \LoggerInterface ;
4448use Throwable ;
4549
@@ -63,6 +67,7 @@ public function __construct(
6367 private ProvisioningService $ provisioningService ,
6468 private LdapService $ ldapService ,
6569 private IUserManager $ userManager ,
70+ private ServerVersion $ serverVersion ,
6671 ) {
6772 }
6873
@@ -391,9 +396,9 @@ private function checkFirstLogin(string $userId): bool {
391396
392397 $ firstLogin = $ user ->getLastLogin () === 0 ;
393398 if ($ firstLogin ) {
394- \OC_Util::setupFS ($ userId );
399+ $ this -> serverVersion -> getMajorVersion () >= 34 ? Server:: get (ISetupManager::class)-> setupForUser ( $ user ) : \OC_Util::setupFS ($ userId );
395400 // trigger creation of user home and /files folder
396- $ userFolder = \ OC :: $ server ->getUserFolder ($ userId );
401+ $ userFolder = Server:: get (IRootFolder::class) ->getUserFolder ($ userId );
397402 try {
398403 // copy skeleton
399404 \OC_Util::copySkeleton ($ userId , $ userFolder );
@@ -403,8 +408,7 @@ private function checkFirstLogin(string $userId): bool {
403408
404409 // trigger any other initialization
405410 $ this ->eventDispatcher ->dispatch (IUser::class . '::firstLogin ' , new GenericEvent ($ user ));
406- // TODO add this when user_oidc min NC version is >= 28
407- // $this->eventDispatcher->dispatchTyped(new UserFirstTimeLoggedInEvent($user));
411+ $ this ->eventDispatcher ->dispatchTyped (new UserFirstTimeLoggedInEvent ($ user ));
408412 }
409413 $ user ->updateLastLoginTimestamp ();
410414 return $ firstLogin ;
0 commit comments