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

Examples bump supertokens #22764

Merged
merged 2 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions examples/with-supertokens/.env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,15 @@ NEXT_PUBLIC_APP_URL="http://localhost:3000"

# Secret environment variables only available to Node.js
APP_URL="http://localhost:3000"

## Github
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=

## Google
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=

## Facebook
FACEBOOK_CLIENT_ID=
FACEBOOK_CLIENT_SECRET=
4 changes: 2 additions & 2 deletions examples/with-supertokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"next": "latest",
"react": "17.0.1",
"react-dom": "17.0.1",
"supertokens-auth-react": "^0.6.0",
"supertokens-node": "^4.0.0"
"supertokens-auth-react": "^0.7.0",
"supertokens-node": "^4.1.0"
},
"license": "MIT"
}
33 changes: 29 additions & 4 deletions examples/with-supertokens/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import '../styles/globals.css'
import React from 'react'
import SuperTokensReact from 'supertokens-auth-react'
import EmailPasswordReact from 'supertokens-auth-react/recipe/emailpassword'
import ThirdPartyEmailPasswordReact from 'supertokens-auth-react/recipe/thirdpartyemailpassword'
import SessionReact from 'supertokens-auth-react/recipe/session'
import SuperTokensNode from 'supertokens-node'
import SessionNode from 'supertokens-node/recipe/session'
import EmailPasswordNode from 'supertokens-node/recipe/emailpassword'
import ThirdPartyEmailPasswordNode from 'supertokens-node/recipe/thirdpartyemailpassword'
const port = process.env.APP_PORT || 3000
const websiteDomain =
process.env.APP_URL ||
Expand All @@ -24,10 +24,17 @@ if (typeof window !== 'undefined') {
apiBasePath,
},
recipeList: [
EmailPasswordReact.init({
ThirdPartyEmailPasswordReact.init({
emailVerificationFeature: {
mode: 'REQUIRED',
},
signInAndUpFeature: {
providers: [
ThirdPartyEmailPasswordReact.Google.init(),
ThirdPartyEmailPasswordReact.Github.init(),
ThirdPartyEmailPasswordReact.Facebook.init(),
],
},
}),
SessionReact.init(),
],
Expand All @@ -44,7 +51,25 @@ if (typeof window !== 'undefined') {
apiDomain: websiteDomain,
apiBasePath,
},
recipeList: [EmailPasswordNode.init(), SessionNode.init()],
recipeList: [
ThirdPartyEmailPasswordNode.init({
providers: [
ThirdPartyEmailPasswordNode.Google({
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
clientId: process.env.GOOGLE_CLIENT_ID,
}),
ThirdPartyEmailPasswordNode.Github({
clientSecret: process.env.GITHUB_CLIENT_SECRET,
clientId: process.env.GITHUB_CLIENT_ID,
}),
ThirdPartyEmailPasswordNode.Facebook({
clientSecret: process.env.FACEBOOK_CLIENT_SECRET,
clientId: process.env.FACEBOOK_CLIENT_ID,
}),
],
}),
SessionNode.init(),
],
})
}

Expand Down
15 changes: 9 additions & 6 deletions examples/with-supertokens/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import React from 'react'
import Head from 'next/head'
import styles from '../styles/Home.module.css'
import EmailPassword from 'supertokens-auth-react/recipe/emailpassword'
import ThirdPartyEmailPassword from 'supertokens-auth-react/recipe/thirdpartyemailpassword'
import dynamic from 'next/dynamic'

const EmailPasswordAuthNoSSR = dynamic(
() => Promise.resolve().then(() => EmailPassword.EmailPasswordAuth),
const ThirdPartyEmailPasswordAuthNoSSR = dynamic(
() =>
Promise.resolve().then(
() => ThirdPartyEmailPassword.ThirdPartyEmailPasswordAuth
),
{
ssr: false,
}
)

export default function Home() {
async function logoutClicked() {
await EmailPassword.signOut()
await ThirdPartyEmailPassword.signOut()
window.location.href = '/auth'
}

Expand All @@ -34,7 +37,7 @@ export default function Home() {
<h1 className={styles.title}>
Welcome to <a href="https://nextjs.org">Next.js!</a>
</h1>
<EmailPasswordAuthNoSSR>
<ThirdPartyEmailPasswordAuthNoSSR>
<p className={styles.description}>
You are authenticated with SuperTokens!
</p>
Expand Down Expand Up @@ -95,7 +98,7 @@ export default function Home() {
FETCH USER API
</div>
</div>
</EmailPasswordAuthNoSSR>
</ThirdPartyEmailPasswordAuthNoSSR>

<div className={styles.grid}>
<a href="https://nextjs.org/docs" className={styles.card}>
Expand Down