Skip to content

Commit 3b1973c

Browse files
committed
Add authenticate HOF for server actions
:q
1 parent 5bfbbd1 commit 3b1973c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1594
-1419
lines changed

examples/with-next-ssr-app-directory/app/actions/checkSSRSession.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import { ssrConfig } from "../config/ssr";
77

88
init(ssrConfig());
99

10-
export async function checkSSRSession(e) {
11-
const cookiesStore = await cookies();
12-
// const session = await getServerComponentSession(cookiesStore);
13-
const session = await getServerActionSession(cookiesStore);
10+
export async function checkSSRSession(session) {
11+
// const session = await getServerActionSession(cookiesStore);
1412

15-
console.log(session);
13+
console.log("session", session);
1614
return Promise.resolve(true);
1715
}

examples/with-next-ssr-app-directory/app/components/ssrButton.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,23 @@
11
"use client";
22

33
import { checkSSRSession } from "../actions/checkSSRSession";
4+
import { authenticateServerAction, init } from "supertokens-auth-react/nextjs/ssr";
45
import styles from "../page.module.css";
6+
import { ssrConfig } from "../config/ssr";
7+
8+
import { getAccessToken, attemptRefreshingSession } from "supertokens-web-js/recipe/session";
9+
10+
init(ssrConfig());
511

612
export const SSRButton = () => {
713
return (
814
<div
915
style={{ marginTop: "20px" }}
1016
onClick={async (e) => {
11-
await checkSSRSession(e);
17+
// const session = await getAccessToken();
18+
// console.log("sessionn in component", session);
19+
const result = await authenticateServerAction(checkSSRSession);
20+
console.log(result);
1221
}}
1322
className={styles.sessionButton}
1423
>

examples/with-next-ssr-app-directory/app/config/backend.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export let backendConfig = (): TypeInput => {
1313
// debug: true,
1414
supertokens: {
1515
// this is the location of the SuperTokens core.
16-
connectionURI: "https://st-dev-bc3c6f90-79ba-11ef-ab9e-9bd286159eeb.aws.supertokens.io",
17-
apiKey: "e9zZOI7yJ0-G6gms7iGKZ17Pb-",
16+
// connectionURI: "https://st-dev-bc3c6f90-79ba-11ef-ab9e-9bd286159eeb.aws.supertokens.io",
17+
connectionURI: "http://localhost:3567",
18+
// apiKey: "e9zZOI7yJ0-G6gms7iGKZ17Pb-",
1819
},
1920
appInfo,
2021
// recipeList contains all the modules that you want to

examples/with-next-ssr-app-directory/app/config/frontend.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function setRouter(router: ReturnType<typeof useRouter>, pathName: string
1919
export const frontendConfig = (): SuperTokensConfig => {
2020
return {
2121
appInfo,
22-
enableDebugLogs: true,
22+
// enableDebugLogs: true,
2323
recipeList: [
2424
EmailPasswordReact.init(),
2525
ThirdPartyReact.init({

lib/build/authRecipe-shared.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/authRecipe-shared2.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/emailpassword-shared3.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/build/emailpassword.js

Lines changed: 9 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)