mirror of
https://github.com/stack-auth/stack.git
synced 2026-06-30 21:01:54 +08:00
Fix preview-mode logout when opening account settings
In preview mode the dashboard uses an in-memory token store, so the hard reload from redirectToAccountSettings() wipes the session and bounces the user to a sign-in page. Soft-navigate via router.push (app.useNavigate) instead, which preserves the in-memory session.
This commit is contained in:
parent
c749cf2b62
commit
0e0c3a1bab
@ -88,6 +88,9 @@ export function DashboardUserButton(props: DashboardUserButtonProps) {
|
||||
function DashboardUserButtonInner(props: DashboardUserButtonProps) {
|
||||
const user = useUser();
|
||||
const app = useStackApp();
|
||||
// Soft-navigate: redirectToAccountSettings() hard-reloads, which wipes preview mode's
|
||||
// in-memory session and bounces the user to sign-in. router.push keeps the session alive.
|
||||
const navigate = app.useNavigate();
|
||||
const showUserInfo = props.showUserInfo === true;
|
||||
const displayName = user?.displayName ?? user?.primaryEmail ?? "Account";
|
||||
const iconProps = { size: 16, className: menuIconClassName };
|
||||
@ -142,7 +145,7 @@ function DashboardUserButtonInner(props: DashboardUserButtonProps) {
|
||||
{user && (
|
||||
<DashboardMenuItem
|
||||
text="Account settings"
|
||||
onClick={async () => await app.redirectToAccountSettings()}
|
||||
onClick={() => navigate("/handler/account-settings")}
|
||||
icon={<UserCircleIcon {...iconProps} />}
|
||||
/>
|
||||
)}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user