Skip to content

Commit 8bd74db

Browse files
Merge pull request #1065 from nextcloud/fix/noid/login-flow-gss
broadcast prelogin event before login event
2 parents 98f0205 + 51fd227 commit 8bd74db

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

lib/Controller/LoginController.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -517,13 +517,15 @@ public function code(string $state = '', string $code = '', string $scope = '',
517517

518518
$this->userSession->setUser($user);
519519
if ($this->userSession instanceof OC_UserSession) {
520-
$this->userSession->completeLogin($user, ['loginName' => $user->getUID(), 'password' => '']);
521-
$this->userSession->createSessionToken($this->request, $user->getUID(), $user->getUID());
522-
$this->userSession->createRememberMeToken($user);
523520
// TODO server should/could be refactored so we don't need to manually create the user session and dispatch the login-related events
524521
// Warning! If GSS is used, it reacts to the BeforeUserLoggedInEvent and handles the redirection itself
525522
// So nothing after dispatching this event will be executed
526-
$this->eventDispatcher->dispatchTyped(new BeforeUserLoggedInEvent($user->getUID(), null, \OC::$server->get(Backend::class)));
523+
$this->eventDispatcher->dispatchTyped(new BeforeUserLoggedInEvent($user->getUID(), null, \OCP\Server::get(Backend::class)));
524+
525+
$this->userSession->completeLogin($user, ['loginName' => $user->getUID(), 'password' => '']);
526+
$this->userSession->createSessionToken($this->request, $user->getUID(), $user->getUID());
527+
$this->userSession->createRememberMeToken($user);
528+
527529
$this->eventDispatcher->dispatchTyped(new UserLoggedInEvent($user, $user->getUID(), null, false));
528530
}
529531

0 commit comments

Comments
 (0)