Skip to content

Commit

Permalink
fix: invalidate cache when log in/out
Browse files Browse the repository at this point in the history
  • Loading branch information
exKAZUu committed Jan 12, 2024
1 parent 4b674f7 commit 6f58f40
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/app/(withAuth)/courses/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const CoursePage: NextPage = async () => {
<main>
<div>UserID: {session.getUserId()}</div>
<h1>Courses</h1>
<ul>{}</ul>
</main>
);
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/organisms/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { usePathname, useRouter } from 'next/navigation';
import React from 'react';
import { SuperTokensWrapper } from 'supertokens-auth-react';

import { ensureSuperTokensReactInit, setRouter } from '../../infrastructures/supertokens/frontend';
import { ensureSuperTokensReactInit, setRouter } from '../../infrastructures/supertokens/frontendConfig';
import { theme } from '../../theme';

ensureSuperTokensReactInit();
Expand Down
1 change: 1 addition & 0 deletions src/components/organisms/SignOutMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const SignOutMenuItem: React.FC = () => {
onClick={async () => {
await signOut();
router.push('/');
router.refresh();
}}
>
サインアウト
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import EmailPasswordReact from 'supertokens-auth-react/recipe/emailpassword';
import SessionReact from 'supertokens-auth-react/recipe/session';

import { appInfo } from './appInfo';
import { router } from 'next/client';

const routerInfo: { router?: ReturnType<typeof useRouter>; pathName?: string } = {};

Expand All @@ -16,7 +17,14 @@ export function setRouter(router: ReturnType<typeof useRouter>, pathName: string
export const frontendConfig = (): SuperTokensConfig => {
return {
appInfo,
recipeList: [EmailPasswordReact.init(), SessionReact.init()],
recipeList: [
EmailPasswordReact.init({
onHandleEvent: async (context) => {
router.referesh();
},
}),
SessionReact.init(),
],
windowHandler: (original) => ({
...original,
location: {
Expand Down

0 comments on commit 6f58f40

Please sign in to comment.