mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-09-13 12:15:29 +02:00
Fix username display issues (#6471)
# Description of Changes Main fixes: - Fix the display of the username in the bottom left - Now displays as "User" when not logged in on self-hosted (desktop) and "Guest" on SaaS when logged in anonymously - Now updates properly when the user logs in/out in SaaS, desktop and self-hosted - Fix incremental build issues in the desktop app that have been here since the start (I hope at least - I think the issue is that the JLink is built read-only and then on subsequent builds you get OS errors when trying to override the JLink with the new version. There's no real need for it to be read-only that I know of, so we might as well just make it R/W and ship like that)
This commit is contained in:
@@ -7,9 +7,11 @@ import {
|
||||
} from "@app/services/connectionModeService";
|
||||
import { authService, UserInfo } from "@app/services/authService";
|
||||
import { OPEN_SIGN_IN_EVENT } from "@app/constants/signInEvents";
|
||||
import { useAuth } from "@app/auth/UseSession";
|
||||
|
||||
export const ConnectionSettings: React.FC = () => {
|
||||
const { t } = useTranslation();
|
||||
const { signOut } = useAuth();
|
||||
const [config, setConfig] = useState<ConnectionConfig | null>(null);
|
||||
const [userInfo, setUserInfo] = useState<UserInfo | null>(null);
|
||||
const [loading, setLoading] = useState(false);
|
||||
@@ -43,7 +45,22 @@ export const ConnectionSettings: React.FC = () => {
|
||||
if (config?.mode === "selfhosted" && config?.server_config?.url) {
|
||||
localStorage.setItem("server_url", config.server_config.url);
|
||||
}
|
||||
await authService.logout();
|
||||
// Use the proprietary signOut (which also fans out the SIGNED_OUT event
|
||||
// to the AuthProvider so the React tree sees the unauthenticated state)
|
||||
// and treat authService.logout() as a fallback if it errors. The previous
|
||||
// implementation only called authService.logout() directly, which cleared
|
||||
// the Tauri-stored token+user_info but left the proprietary AuthProvider's
|
||||
// session state stale - so the FileSidebar badge kept showing the prior
|
||||
// user's name until the next session check happened to fire.
|
||||
try {
|
||||
await signOut();
|
||||
} catch (signOutError) {
|
||||
console.warn(
|
||||
"[ConnectionSettings] signOut() failed, falling back to authService.logout()",
|
||||
signOutError,
|
||||
);
|
||||
await authService.logout();
|
||||
}
|
||||
// Always switch to local after logout so the app remains usable
|
||||
await connectionModeService.switchToLocal();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user