NodeJS creating local user after signup

Hi,

I have been testing out a few auth providers for a new webbased application I am writing. I have been testing out Auth0 for the past day and I have run into an issue with locally storing a userid/user profile for use in the app. I am using a regular NodeJS app with EJS views (no API/SPA). I want the users to be able to both use socials or user/password to log into their account.

I have been able to use the express-openid-connect package for handling the universal login/signup portal provided by Auth0 for user signup and login. This by using the auth and requiresAuth middleware on its standard routes. However I am unsure on how to proceed with storing the userinformation locally after their first login. The ability to do this is essential to the app and with Stytch this was pretty straight forward however with Auth0 this has been a bit of a nightmare at the moment.

I have tried using the afterCallback config in the auth middleware, however when using this it causes some really strange behaviour in the webapp with constant reloads, here is the code I have been using:

const openIdConfig = {
  authRequired: false,
  auth0Logout: true,
  baseURL: 'http://localhost:3000',
  clientID: 'XXX',
  issuerBaseURL: XXX,
  secret: 'XXX',
  afterCallback: (req, res, session, decodedState) => {
    console.log(req);

    return session;
  },
};

app.use(auth(openIdConfig));

I am literally trying to just log the variables I get back after the callback, maybe I have misunderstood its purpose, what would be the best way to locally store some identifiable user data that comes back from Auth0 when a user gets created with either username/password or socials signup?