nextauthjs / next-auth

Authentication for the Web.
https://authjs.dev
ISC License
23.26k stars 3.18k forks source link

Sveltekit + surrealdb-adapter + email magic link login does not work #9441

Open Z-snails opened 6 months ago

Z-snails commented 6 months ago

Environment

System: OS: Linux 6.5 Pop!_OS 22.04 LTS CPU: (12) x64 AMD Ryzen 5 5625U with Radeon Graphics Memory: 8.56 GB / 14.97 GB Container: Yes Shell: 5.1.16 - /bin/bash Binaries: Node: 20.2.0 - ~/.asdf/installs/nodejs/20.2.0/bin/node npm: 9.6.6 - ~/.asdf/plugins/nodejs/shims/npm pnpm: 8.12.1 - ~/.local/share/pnpm/pnpm bun: 0.7.3 - ~/.bun/bin/bun Browsers: Chromium: 120.0.6099.71 npmPackages: @auth/core: ^0.19.0 => 0.19.0 @auth/surrealdb-adapter: ^0.2.6 => 0.2.6 @auth/sveltekit: ^0.5.0 => 0.5.0

Reproduction URL

https://github.com/Z-snails/authjs-email-error

Describe the issue

When signing in with email, after clicking the sign in link in the email, the following error occurs (with full log of a sign in)

[auth][error] TypeError: option expires is invalid
[auth][warn][debug-enabled] Read more: https://warnings.authjs.dev#debug-enabled
[auth][debug]: adapter_getUserByEmail {
  "args": [
    "<my email>"
  ]
}
[auth][debug]: adapter_createVerificationToken {
  "args": [
    {
      "identifier": "<my email>",
      "token": "...",
      "expires": "2023-12-23T09:40:26.862Z"
    }
  ]
}
[auth][debug]: adapter_useVerificationToken {
  "args": [
    {
      "identifier": "<my email>",
      "token": "..."
    }
  ]
}
[auth][debug]: adapter_getUserByEmail {
  "args": [
    "<my email>"
  ]
}
[auth][debug]: adapter_getUserByEmail {
  "args": [
    "<my email>"
  ]
}
[auth][debug]: adapter_updateUser {
  "args": [
    {
      "id": "⟨b204504e-3d69-4dbb-af93-9b5cddcabcdc⟩",
      "emailVerified": "2023-12-22T09:40:40.114Z"
    }
  ]
}
[auth][debug]: adapter_createSession {
  "args": [
    {
      "sessionToken": "...",
      "userId": "⟨b204504e-3d69-4dbb-af93-9b5cddcabcdc⟩",
      "expires": "2024-01-21T09:40:40.115Z"
    }
  ]
}
[auth][error] TypeError: option expires is invalid
    at serialize (~/auth-test/node_modules/.pnpm/cookie@0.6.0/node_modules/cookie/index.js:161:13)
    at ~/auth-test/node_modules/.pnpm/@auth+core@0.19.0_nodemailer@6.9.7/node_modules/@auth/core/lib/utils/web.js:76:30
    at Array.forEach (<anonymous>)
    at toResponse (~/auth-test/node_modules/.pnpm/@auth+core@0.19.0_nodemailer@6.9.7/node_modules/@auth/core/lib/utils/web.js:74:18)
    at Module.Auth (~/auth-test/node_modules/.pnpm/@auth+core@0.19.0_nodemailer@6.9.7/node_modules/@auth/core/index.js:107:26)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Module.respond (~/auth-test/node_modules/.pnpm/@sveltejs+kit@2.0.6_@sveltejs+vite-plugin-svelte@3.0.1_svelte@4.2.8_vite@5.0.10/node_modules/@sveltejs/kit/src/runtime/server/respond.js:291:20)
    at async ~/auth-test/node_modules/.pnpm/@sveltejs+kit@2.0.6_@sveltejs+vite-plugin-svelte@3.0.1_svelte@4.2.8_vite@5.0.10/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:502:22
q

How to reproduce

Expected behavior

I should be logged in and a login cookie should be saved in my browser. Neither of these occur, instead an error 500 is returned.

Although the user shows as verified in the database.

dexterIshere commented 5 months ago

hi same problem here, do you know why ? finaly ??