Skip to content

Is there any way to access original request in signin callback? #469

Answered by dan-kwiat
eak12913 asked this question in Help
Discussion options

You must be logged in to vote

My solution to a similar use case is to set a cookie inside the getServerSideProps method of the initial invite page. Then read the cookie from the callback (or the createUser event):

// [...nextauth].js
const getOptions = (req) => ({
  // providers: [...],
  // database: {...},
  callbacks: {
    signIn: async (user, account, profile) => {
      const { invite_id } = req.cookies
      // do something with invite_id
      return true
    },
  },
})

export default (req, res) => NextAuth(req, res, getOptions(req))

Replies: 4 comments 8 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
7 replies
@dan-kwiat
Comment options

@davevilela
Comment options

@FahimFaisalKhan
Comment options

@goerlitz
Comment options

@drattansingh
Comment options

Answer selected by eak12913
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@drattansingh
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
10 participants
Converted from issue

This discussion was converted from issue #469 on December 07, 2020 17:14.