-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-solid-start
- Loading branch information
Showing
104 changed files
with
2,748 additions
and
447 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,13 +71,13 @@ jobs: | |
runs-on: ubuntu-latest | ||
steps: | ||
- name: Init | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Install pnpm | ||
uses: pnpm/[email protected] | ||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 18 | ||
cache: "pnpm" | ||
|
@@ -88,33 +88,49 @@ jobs: | |
if: ${{ github.repository == 'nextauthjs/next-auth' && github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
- name: Build | ||
run: pnpm build | ||
- name: Run tests | ||
- name: Run unit tests | ||
if: false | ||
run: pnpm test | ||
timeout-minutes: 15 | ||
env: | ||
UPSTASH_REDIS_URL: ${{ secrets.UPSTASH_REDIS_URL }} | ||
UPSTASH_REDIS_KEY: ${{ secrets.UPSTASH_REDIS_KEY }} | ||
- name: Get installed Playwright version | ||
id: playwright-version | ||
run: echo "PLAYWRIGHT_VERSION=$(pnpx playwright -V | awk '{ print $2 }')" >> $GITHUB_ENV | ||
- name: Cache playwright binaries | ||
uses: actions/cache@v4 | ||
id: playwright-cache | ||
with: | ||
path: | | ||
~/.cache/ms-playwright | ||
key: ${{ runner.os }}-playwright-${{ env.PLAYWRIGHT_VERSION }} | ||
- name: Install Playwright | ||
if: steps.playwright-cache.outputs.cache-hit != 'true' && github.repository == 'nextauthjs/next-auth' | ||
run: | | ||
pnpm exec playwright install --with-deps chromium | ||
- name: Run E2E tests | ||
continue-on-error: true # TODO: Make this less flakey | ||
if: github.repository == 'nextauthjs/next-auth' | ||
timeout-minutes: 15 | ||
run: | | ||
pnpm exec playwright install --with-deps > /dev/null 2>&1 | ||
pnpm test:e2e | ||
timeout-minutes: 15 | ||
env: | ||
AUTH_SECRET: ${{ secrets.AUTH_SECRET }} | ||
TEST_KEYCLOAK_USERNAME: ${{ secrets.TEST_KEYCLOAK_USERNAME }} | ||
TEST_KEYCLOAK_PASSWORD: ${{ secrets.TEST_KEYCLOAK_PASSWORD }} | ||
AUTH_KEYCLOAK_ID: ${{ secrets.AUTH_KEYCLOAK_ID }} | ||
AUTH_KEYCLOAK_SECRET: ${{ secrets.AUTH_KEYCLOAK_SECRET }} | ||
AUTH_KEYCLOAK_ISSUER: ${{ secrets.AUTH_KEYCLOAK_ISSUER }} | ||
AUTH_TRUST_HOST: 1 | ||
- uses: actions/upload-artifact@v3 | ||
name: Upload Playwright report | ||
- uses: actions/upload-artifact@v4 | ||
name: Upload Playwright artifacts | ||
with: | ||
name: playwright-report | ||
path: packages/core/playwright-report/ | ||
retention-days: 30 | ||
name: playwright-traces | ||
path: "**/packages/utils/test-results/*/trace.zip" | ||
retention-days: 7 | ||
- uses: codecov/codecov-action@v3 | ||
if: always() | ||
name: Coverage | ||
with: | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,41 @@ | ||
"use client" | ||
|
||
import { signIn, useSession } from "next-auth/react" | ||
import { signIn, signOut, useSession } from "next-auth/react" | ||
|
||
export default function Client() { | ||
const { data: session, update, status } = useSession() | ||
return ( | ||
<div> | ||
<pre> | ||
{status === "loading" ? "Loading..." : JSON.stringify(session, null, 2)} | ||
</pre> | ||
<button onClick={() => signIn("github")}>Sign in</button> | ||
<button onClick={() => signIn("credentials", {})}>Sign in cred</button> | ||
<button onClick={() => update(`New Name`)}>Update session</button> | ||
<div className="card"> | ||
<div className="card-header"> | ||
<h3>Client Component</h3> | ||
</div> | ||
<div className="card-body"> | ||
<h4>Session</h4> | ||
<pre> | ||
{status === "loading" | ||
? "Loading..." | ||
: JSON.stringify(session, null, 2)} | ||
</pre> | ||
<div className="btn-wrapper"> | ||
{session ? ( | ||
<> | ||
<button | ||
onClick={() => update({ user: { name: "Client Fill Murray" } })} | ||
> | ||
Update Session - New Name | ||
</button> | ||
<button onClick={() => signOut()}>Sign out</button> | ||
</> | ||
) : ( | ||
<> | ||
<button onClick={() => signIn("github")}>Sign in Github</button> | ||
<button onClick={() => signIn("credentials", {})}> | ||
Sign in Credentials | ||
</button> | ||
</> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,44 @@ | ||
import { auth, unstable_update as update } from "auth" | ||
import { SessionProvider } from "next-auth/react" | ||
import { auth } from "auth" | ||
import Client from "./client" | ||
|
||
export default async function Page() { | ||
const session = await auth() | ||
return ( | ||
<> | ||
<div className="container"> | ||
<h1>NextAuth.js Example</h1> | ||
<p> | ||
This is an example site to demonstrate how to use{" "} | ||
<a href="https://nextjs.authjs.dev">NextAuth.js</a> for authentication. | ||
</p> | ||
<div className="card"> | ||
<div className="card-header"> | ||
<h3>Server Action</h3> | ||
</div> | ||
<div className="card-body"> | ||
{session ? ( | ||
<form | ||
action={async () => { | ||
"use server" | ||
update({ user: { name: "Server Fill Murray" } }) | ||
}} | ||
> | ||
<button>Update Session - New Name</button> | ||
</form> | ||
) : null} | ||
</div> | ||
<div className="card-footer"> | ||
Note: The "Sign in" button in the header is using{" "} | ||
<b>server form actions</b>. | ||
</div> | ||
</div> | ||
{/* | ||
NOTE: The `auth()` result is not run through the `session` callback, be careful passing down data | ||
to a client component, this will be exposed via the /api/auth/session endpoint | ||
*/} | ||
<SessionProvider session={session} basePath="/auth"> | ||
<Client /> | ||
</SessionProvider> | ||
<h1>NextAuth.js Example</h1> | ||
<p> | ||
This is an example site to demonstrate how to use{" "} | ||
<a href="https://nextjs.authjs.dev">NextAuth.js</a> for authentication. | ||
</p> | ||
</> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,20 +19,18 @@ declare module "next-auth" { | |
} | ||
|
||
interface User { | ||
foo: string | ||
foo?: string | ||
} | ||
} | ||
|
||
export default { | ||
debug: false, | ||
providers: [ | ||
Credentials({ | ||
credentials: { password: { label: "Password", type: "password" } }, | ||
authorize(c) { | ||
if (c.password !== "password") return null | ||
return { | ||
id: "test", | ||
foo: "bar", | ||
name: "Test User", | ||
email: "[email protected]", | ||
} | ||
|
@@ -50,6 +48,14 @@ export default { | |
if (trigger === "update") token.name = session.user.name | ||
return token | ||
}, | ||
async session({ session, token, trigger }) { | ||
return { | ||
...session, | ||
user: { | ||
...token, | ||
}, | ||
} | ||
}, | ||
}, | ||
basePath: "/auth", | ||
} satisfies NextAuthConfig |
Oops, something went wrong.