Skip to content

Commit

Permalink
chore: update pnpm-lock, prettier, prisma types (#12414)
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 authored Dec 22, 2024
1 parent fd04b35 commit 9471abe
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 86 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ env:
jobs:
test:
name: Test
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Init
uses: actions/checkout@v4
Expand Down
37 changes: 19 additions & 18 deletions docs/pages/getting-started/authentication/credentials.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -329,27 +329,28 @@ export default component$(() => {
<Code.Express>

```html filename="views/signin.html"
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sign In</title>
</head>
<body>
<h1>Sign In</h1>
<form action="/auth/signin" method="POST">
<label for="email">Email:</label>
<input type="email" name="email" id="email" required />
<br />
<label for="password">Password:</label>
<input type="password" name="password" id="password" required />
<br />
<button type="submit">Sign In</button>
</form>
</body>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sign In</title>
</head>
<body>
<h1>Sign In</h1>
<form action="/auth/signin" method="POST">
<label for="email">Email:</label>
<input type="email" name="email" id="email" required />
<br />
<label for="password">Password:</label>
<input type="password" name="password" id="password" required />
<br />
<button type="submit">Sign In</button>
</form>
</body>
</html>
```

</Code.Express>

</Code>
Expand Down
53 changes: 28 additions & 25 deletions docs/pages/getting-started/providers/frontegg.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -44,47 +44,50 @@ Follow these steps:

Log into the [Frontegg portal](https://portal.frontegg.com)

Get the following from the Frontegg's portal:
Add the required environment variables to your `.env.local` file.

AUTH_FRONTEGG_ID="<Client ID>" # Environments > Your environment > Env settings
AUTH_FRONTEGG_SECRET="<API KEY>" # Environments > Your environment > Env settings
AUTH_FRONTEGG_ISSUER="<https://[YOUR_SUBDOMAIN].frontegg.com>" # Environments > Your environment > Env settings > Domains > Domain name

Add the required environment variables from above to your `.env.local` file.
```
# Environments > Your environment > Env settings
AUTH_FRONTEGG_ID="<Client ID>"
# Environments > Your environment > Env settings
AUTH_FRONTEGG_SECRET="<API KEY>"
# Environments > Your environment > Env settings > Domains > Domain name
AUTH_FRONTEGG_ISSUER="<https://[YOUR_SUBDOMAIN].frontegg.com>"
```

<Code>
<Code.Next>

```ts filename="/auth.ts"
import NextAuth from "next-auth"
import Frontegg from "next-auth/providers/frontegg"
```ts filename="/auth.ts"
import NextAuth from "next-auth"
import Frontegg from "next-auth/providers/frontegg"

export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [Frontegg],
})
```
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [Frontegg],
})
```

</Code.Next>
<Code.Svelte>

```ts filename="/src/auth.ts"
import { SvelteKitAuth } from "@auth/sveltekit"
import Frontegg from "@auth/sveltekit/providers/frontegg"
```ts filename="/src/auth.ts"
import { SvelteKitAuth } from "@auth/sveltekit"
import Frontegg from "@auth/sveltekit/providers/frontegg"

export const { handle, signIn, signOut } = SvelteKitAuth({
providers: [Frontegg],
})
```
export const { handle, signIn, signOut } = SvelteKitAuth({
providers: [Frontegg],
})
```

</Code.Svelte>
<Code.Express>

```ts filename="/src/app.ts"
import { ExpressAuth } from "@auth/express"
import Frontegg from "@auth/express/providers/frontegg"
```ts filename="/src/app.ts"
import { ExpressAuth } from "@auth/express"
import Frontegg from "@auth/express/providers/frontegg"

app.use("/auth/*", ExpressAuth({ providers: [Frontegg] }))
```
app.use("/auth/*", ExpressAuth({ providers: [Frontegg] }))
```

</Code.Express>
</Code>
8 changes: 4 additions & 4 deletions docs/pages/guides/refresh-token-rotation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ export const { handlers, auth } = NextAuth({
return {
...token,
access_token: newTokens.access_token,
expires_at: Math.floor(
Date.now() / 1000 + newTokens.expires_in
),
expires_at: Math.floor(Date.now() / 1000 + newTokens.expires_in),
// Some providers only issue refresh tokens once, so preserve if we did not get a new one
refresh_token: newTokens.refresh_token ? newTokens.refresh_token : token.refresh_token
refresh_token: newTokens.refresh_token
? newTokens.refresh_token
: token.refresh_token,
}
} catch (error) {
console.error("Error refreshing access_token", error)
Expand Down
18 changes: 11 additions & 7 deletions packages/adapter-prisma/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*
* @module @auth/prisma-adapter
*/
import type { PrismaClient, Prisma } from "@prisma/client"
import { type PrismaClient } from "@prisma/client"
import { PrismaClientKnownRequestError } from "@prisma/client/runtime/library"
import type {
Adapter,
AdapterAccount,
Expand Down Expand Up @@ -73,22 +74,25 @@ export function PrismaAdapter(
const verificationToken = await p.verificationToken.create(
stripUndefined(data)
)
// @ts-expect-errors // MongoDB needs an ID, but we don't
if (verificationToken.id) delete verificationToken.id
if ("id" in verificationToken && verificationToken.id)
delete verificationToken.id
return verificationToken
},
async useVerificationToken(identifier_token) {
try {
const verificationToken = await p.verificationToken.delete({
where: { identifier_token },
})
// @ts-expect-errors // MongoDB needs an ID, but we don't
if (verificationToken.id) delete verificationToken.id
if ("id" in verificationToken && verificationToken.id)
delete verificationToken.id
return verificationToken
} catch (error) {
} catch (error: unknown) {
// If token already used/deleted, just return null
// https://www.prisma.io/docs/reference/api-reference/error-reference#p2025
if ((error as Prisma.PrismaClientKnownRequestError).code === "P2025")
if (
error instanceof PrismaClientKnownRequestError &&
error.code === "P2025"
)
return null
throw error
}
Expand Down
60 changes: 29 additions & 31 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9471abe

Please sign in to comment.