Skip to content

No session is returned after Credentials login #4144

Answered by leo-petrucci
leo-petrucci asked this question in Help
Discussion options

You must be logged in to vote

So obviously as soon as I posted this I found a solution. Apparently when using credentials you need to manually encode/decode your JWT.

  session: {
    strategy: "jwt",
  },
  jwt: {
    async encode({ token }) {
      return jwt.sign(token as {}, process.env.JWT_SECRET!);
    },
    async decode({ token }) {
      return jwt.verify(token!, process.env.JWT_SECRET!) as JWT;
    },
  },

Specifying the session strategy is also required.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@stgogm
Comment options

@Eugene-Mokrushin
Comment options

@abibring
Comment options

@mwarnerdotme
Comment options

@ak800i
Comment options

Answer selected by leo-petrucci
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
7 participants