Skip to content

Commit 52b9b72

Browse files
committed
fix: do not cache getAuthenticatedUser call
1 parent 9b73020 commit 52b9b72

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

site/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
<meta property="og:type" content="website" />
1818
<meta property="csrf-token" content="{{ .CSRF.Token }}" />
1919
<meta property="build-info" content="{{ .BuildInfo }}" />
20-
<meta property="user" content="{{ .User }}" />
2120
<meta property="entitlements" content="{{ .Entitlements }}" />
2221
<meta property="appearance" content="{{ .Appearance }}" />
2322
<meta property="experiments" content="{{ .Experiments }}" />

site/src/api/queries/users.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ import {
55
GetUsersResponse,
66
UpdateUserPasswordRequest,
77
UpdateUserProfileRequest,
8-
User,
98
UsersRequest,
109
} from "api/typesGenerated";
11-
import { getMetadataAsJSON } from "utils/metadata";
1210
import { getAuthorizationKey } from "./authCheck";
1311

1412
export const users = (req: UsersRequest): UseQueryOptions<GetUsersResponse> => {
@@ -89,21 +87,11 @@ export const authMethods = () => {
8987
};
9088
};
9189

92-
const initialMeData = getMetadataAsJSON<User>("user");
93-
const meKey = ["me"] as const;
94-
95-
export const me = (queryClient: QueryClient) => {
90+
export const me = () => {
9691
return {
97-
queryKey: meKey,
98-
queryFn: async () => {
99-
const cachedData = queryClient.getQueryData(meKey);
100-
if (cachedData === undefined && initialMeData !== undefined) {
101-
return initialMeData;
102-
}
103-
104-
return API.getAuthenticatedUser();
105-
},
106-
} satisfies UseQueryOptions<User>;
92+
queryKey: ["me"],
93+
queryFn: async () => API.getAuthenticatedUser(),
94+
};
10795
};
10896

10997
export const hasFirstUser = () => {

site/src/components/AuthProvider/AuthProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const AuthContext = createContext<AuthContextValue | undefined>(undefined);
4646

4747
export const AuthProvider: FC<PropsWithChildren> = ({ children }) => {
4848
const queryClient = useQueryClient();
49-
const meOptions = me(queryClient);
49+
const meOptions = me();
5050

5151
const userQuery = useQuery(meOptions);
5252
const authMethodsQuery = useQuery(authMethods());

0 commit comments

Comments
 (0)