question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't complete the upgrade to v4, issues in documentation

See original GitHub issue

Question 💬

Hey folks,

I was running through the migration guide. Everything went smoothly, up to the point where I had to make some changes in the data model.

Here are the issues that I’ve faced:

  1. I’ve renamed all fields email_verified as expected. But I had an error, because the User table still requires emailVerified. The guide is wrong, but the error was straightforward and I was able to fix it
  2. There’s no indication that the table verification_requests is now verification_tokens. Again, error was clear enough, I could fix it on my own
  3. I can’t request a new token by email. I’ve got the following error:
[next-auth][error][SIGNIN_EMAIL_ERROR] 
https://next-auth.js.org/errors#signin_email_error date/time field value out of range: "1635236284553" QueryFailedError: date/time field value out of range: "1635236284553"
    at QueryFailedError.TypeORMError [as constructor] (/Users/lionelrudaz/Sites/tasters/node_modules/typeorm/error/TypeORMError.js:9:28)
    at new QueryFailedError (/Users/lionelrudaz/Sites/tasters/node_modules/typeorm/error/QueryFailedError.js:13:28)
    at PostgresQueryRunner.<anonymous> (/Users/lionelrudaz/Sites/tasters/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:277:31)
    at step (/Users/lionelrudaz/Sites/tasters/node_modules/tslib/tslib.js:143:27)
    at Object.throw (/Users/lionelrudaz/Sites/tasters/node_modules/tslib/tslib.js:124:57)
    at rejected (/Users/lionelrudaz/Sites/tasters/node_modules/tslib/tslib.js:115:69)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:93:5) {
  name: 'CreateVerificationTokenError'

There’s no document explaining what I should do with that. Can you help me with this?

Let me know if you need more information.

How to reproduce ☕️

Explained in the description.

Contributing 🙌🏽

Yes, I am willing to help answer this question in a PR

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
davecarlsoncommented, Nov 30, 2021

Nevermind, finally got something working. I think the docs need extending in the example, and the augmentation is wrong.

types/next-auth.d.ts

import NextAuth from "next-auth"

global {
    declare module "next-auth" {
    /**
     * Returned by `useSession`, `getSession` and received as a prop on the `SessionProvider` React Context
     */

    interface User {
      id: string;
      name: string;
      email: string;
    }

    interface Session {
      user: User;
    }
  }
}

[…nextAuth.js]

providers: [
    Credentials({
      async authorize(credentials, req) {
        const user = {
          id: 123,
          name: 'me',
          image: 'photo.jpg',
          email: 'test@test.com'
        }
        return user
      }
],
callbacks: {
      async session({ session, user, token }) {
      session.user = {
        ...session.user,
        id: token.id
      }
      return session
}
0reactions
Zertzcommented, Jan 17, 2022

Unless I’m also missing something, it seems like the documentation is indeed slightly incomplete. Building on on @davecarlson’s solution, I came up with this:

types/next-auth.d.ts

declare module "next-auth" {
  interface User extends Session["User"] {
    role: "admin" | "user";
  }

  interface Session {
    user: User;
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshoot Visual Studio installation and upgrade issues
This troubleshooting guide includes step-by-step instructions that should resolve most installation issues.
Read more >
Migrating from v3 to v4 - Gatsby
Introduction. This is a reference for upgrading your site from Gatsby 3 to Gatsby 4. Version 4 introduces big performance improvements of up...
Read more >
Verification, Updates, and Corrections - FSA Partner Connect
4 -Verification attempted, issues found with HS completion. (You received the SEP and acceptable documentation of identity, but you didn't get HS completion ......
Read more >
Upgrading GitLab
Upgrade to a version that is not impacted by this issue. The following upgrade paths are available for impacted versions: 15.2.5 –> 15.3.5;...
Read more >
Upgrading - MoodleDocs
Notes: You can only upgrade to Moodle 4.1 from Moodle 3.9 or later. If upgrading from earlier versions, you must upgrade to 3.9...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found