Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(web): logout and clear user store when using back button on the change password form #6288

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion web/src/routes/auth/login/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<script lang="ts">
import { goto } from '$app/navigation';
import { afterNavigate, goto } from '$app/navigation';
import LoginForm from '$lib/components/forms/login-form.svelte';
import FullscreenContainer from '$lib/components/shared-components/fullscreen-container.svelte';
import { AppRoute } from '$lib/constants';
import { featureFlags, serverConfig } from '$lib/stores/server-config.store';
import { resetSavedUser } from '$lib/stores/user.store';
import { api } from '@api';
import type { PageData } from './$types';

export let data: PageData;

afterNavigate(async ({ from }) => {
if (from?.url.pathname === AppRoute.AUTH_CHANGE_PASSWORD) {
resetSavedUser();
await api.authenticationApi.logout();
}
Comment on lines +14 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBF this should probably be done during the change password process, no? It feels a bit weird to handle it here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is here to handle the case where the user navigate back, using the back button on the browser before changing the password

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh before changing the actual password... I see

});
</script>

{#if $featureFlags.loaded}
Expand Down
Loading