Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: redirect users to/login if their oauth token is invalid#19429

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall 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
18 changes: 16 additions & 2 deletionssite/src/api/queries/users.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -17,6 +17,7 @@ import {
} from "hooks/useEmbeddedMetadata";
import type { UsePaginatedQueryOptions } from "hooks/usePaginatedQuery";
import type {
MutationOptions,
QueryClient,
UseMutationOptions,
UseQueryOptions,
Expand DownExpand Up@@ -192,10 +193,15 @@ const loginFn = async ({
};
};

export const logout = (queryClient: QueryClient) => {
export const logout = (queryClient: QueryClient): MutationOptions => {
return {
mutationFn: API.logout,
onSuccess: () => {
// We're doing this cleanup in `onSettled` instead of `onSuccess` because in the case where an oAuth refresh token has expired this endpoint will return a 401 instead of 200.
onSettled: (_, error) => {
if (error) {
console.error(error);
}

/**
* 2024-05-02 - If we persist any form of user data after the user logs
* out, that will continue to seed the React Query cache, creating
Expand All@@ -210,6 +216,14 @@ export const logout = (queryClient: QueryClient) => {
* Deleting the user data will mean that all future requests have to take
* a full roundtrip, but this still felt like the best way to ensure that
* manually logging out doesn't blow the entire app up.
*
* 2025-08-20 - Since this endpoint is for performing a post logout clean up
* on the backend we should move this local clean up outside of the mutation
* so that it can be explicitly performed even in cases where we don't want
* run the clean up (e.g. when a user is unauthorized). Unfortunately our
* auth logic is too tangled up with some obscured React Query behaviors to
* be able to move right now. After `AuthProvider.tsx` is refactored this
* should be moved.
*/
defaultMetadataManager.clearMetadataByKey("user");
queryClient.removeQueries();
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp