1616use OCP \Authentication \IProvideUserSecretBackend ;
1717use OCP \Authentication \Token \IToken ;
1818use OCP \EventDispatcher \IEventDispatcher ;
19- use OCP \Files \IRootFolder ;
2019use OCP \IGroupManager ;
2120use OCP \IRequest ;
2221use OCP \ISession ;
@@ -150,8 +149,6 @@ public static function loginWithApache(IApacheBackend $backend): bool {
150149 self ::setUserId ($ uid );
151150 /** @var Session $userSession */
152151 $ userSession = Server::get (IUserSession::class);
153-
154- /** @var IEventDispatcher $dispatcher */
155152 $ dispatcher = Server::get (IEventDispatcher::class);
156153
157154 if ($ userSession ->getUser () && !$ userSession ->getUser ()->isEnabled ()) {
@@ -165,11 +162,12 @@ public static function loginWithApache(IApacheBackend $backend): bool {
165162 $ password = $ backend ->getCurrentUserSecret ();
166163 }
167164
168- /** @var IEventDispatcher $dispatcher */
169165 $ dispatcher ->dispatchTyped (new BeforeUserLoggedInEvent ($ uid , $ password , $ backend ));
170166
167+ $ user = $ userSession ->getUser ();
168+ $ userSession ->completeLogin ($ user , ['loginName ' => $ uid , 'password ' => $ password ]);
171169 $ userSession ->createSessionToken ($ request , $ uid , $ uid , $ password );
172- $ userSession ->createRememberMeToken ($ userSession -> getUser () );
170+ $ userSession ->createRememberMeToken ($ user );
173171
174172 if (empty ($ password )) {
175173 $ tokenProvider = Server::get (IProvider::class);
@@ -186,11 +184,6 @@ public static function loginWithApache(IApacheBackend $backend): bool {
186184 }
187185 }
188186
189- $ user = Server::get (IUserManager::class)->get ($ uid );
190-
191- // set up the filesystem
192- Server::get (\OCP \Files \ISetupManager::class)->setupForUser ($ user );
193-
194187 // first call the UserLoggedIn event, the login-process needs to be
195188 // completed before we can safely create the user's folder.
196189 // For example encryption needs to initialize the users keys first
@@ -201,9 +194,6 @@ public static function loginWithApache(IApacheBackend $backend): bool {
201194 null ,
202195 false )
203196 );
204-
205- // trigger creation of user home and /files folder
206- Server::get (IRootFolder::class)->getUserFolder ($ uid );
207197 }
208198 return true ;
209199 }
0 commit comments