Skip to content

Commit

Permalink
fix(next-auth): add code to client SignInResponse (nextauthjs#10943)
Browse files Browse the repository at this point in the history
add error code to SignInResponse

Co-authored-by: Nico Domino <[email protected]>
Co-authored-by: Thang Vu <[email protected]>
  • Loading branch information
3 people authored and k3k8 committed Aug 1, 2024
1 parent 2ad199b commit 264709c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/next-auth/src/lib/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface SignInOptions extends Record<string, unknown> {

export interface SignInResponse {
error: string | undefined
code: string | undefined
status: number
ok: boolean
url: string | null
Expand Down
2 changes: 2 additions & 0 deletions packages/next-auth/src/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,13 +286,15 @@ export async function signIn<
}

const error = new URL(data.url).searchParams.get("error")
const code = new URL(data.url).searchParams.get("code")

if (res.ok) {
await __NEXTAUTH._getSession({ event: "storage" })
}

return {
error,
code,
status: res.status,
ok: res.ok,
url: error ? null : data.url,
Expand Down
2 changes: 2 additions & 0 deletions packages/next-auth/src/webauthn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ export async function signIn<
}

const error = new URL(data.url).searchParams.get("error")
const code = new URL(data.url).searchParams.get("code")

if (res.ok) {
await __NEXTAUTH._getSession({ event: "storage" })
}

return {
error,
code,
status: res.status,
ok: res.ok,
url: error ? null : data.url,
Expand Down

0 comments on commit 264709c

Please sign in to comment.