Getting current User email with Clerk Auth

I am trying to get the Current Users Email in the Auth file so I can create a User in my Model if one does not exist or look it up if it does. I tried this

export const getCurrentUser = async (
  decoded,
  /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
  { token, type },
  /* eslint-disable-next-line @typescript-eslint/no-unused-vars */
  { event, context }
) => {
  if (!decoded) {
    logger.warn('Missing decoded user')
    return null
  }

  console.log('decoded', decoded.email)

  const { id, ..._rest } = decoded

  

  // Be careful to only return information that should be accessible on the web side.
  return { id }
}

But it returns undefined I consoled the whole decoded and it had no user information.

I want to do this but for Clerk

Turned out needed to output the fields from Clerk Dashboard session.

looks like this

2 Likes