Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7214225 authored by theronakpatel's avatar theronakpatel
Browse files

logged in checked first

parent 5328286a
Loading
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -532,11 +532,16 @@ class UserService {
		}

		// Finally, log out the current session if it's the same user (also clears remember-me cookies)
		// Note: In OCC/admin scenarios, isLoggedIn() will be false, so this block won't execute
		if ($logoutCurrentSession) {
			try {
				if ($this->userSession->isLoggedIn() && $this->userSession->getUser() && $this->userSession->getUser()->getUID() === $username) {
				// Check if there's an active session first (safely handles OCC/admin scenarios)
				if ($this->userSession->isLoggedIn()) {
					$currentUser = $this->userSession->getUser();
					if ($currentUser && $currentUser->getUID() === $username) {
						$this->userSession->logout();
					}
				}
			} catch (Exception $e) {
				$this->logger->error($e, ['app' => Application::APP_ID]);
			}