Module issue in Auth0 actions

i want to create a custom action for assigning the user_id to the logged in user based on userID in database but when i testing the custom action it is giving the error as:
action logic code is as :

const ADODB = require("node-adodb");

module.exports = async function onExecutePostLogin(event, api) {
  const { email } = event.user; // Assuming you retrieve the email from the authenticated user object

  // Building connection with MS Access file using ADODB package
  const connection = ADODB.open(
    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db/att2000.mdb;"
  );

  // Query for accessing the database
  const queryResult = () => {
    return `
      SELECT USERID, Email
      FROM USERINFO
      WHERE Email='${email}'
    `;
  };

  try {
    // Retrieve data from the Access database based on the email
    const result = await connection.query(queryResult());

    if (result.length > 0) {
      // Assign the user ID from the database to the logged-in user's user_metadata
      const userId = result[0].USERID;

      // Perform any desired action with the obtained userId, such as updating user metadata in Auth0
      // For example, using Auth0 Management API:
      const auth0 = require('auth0@2.35.0');
      const management = new auth0.ManagementClient({
        domain: 'https://pixako.us.auth0.com',
        clientId: 't21ePuSIQgHLCKbInTN5SQvu38nwg6TJ',
        clientSecret: 'UcRBgMhL9FqI3zvMMdzFcM9QXxMb80MiRg7W05yLR_9UPV--4KLviZzpNhhQM2Xd',
        scope: 'update:users',
      });

      await management.updateUser({ id: event.user.sub }, { user_metadata: { id: userId } });
    }

    // Return the updated event object
    return {
      user: event.user,
      context: event.context,
      stats: {
        loginsCount: event.stats.loginsCount + 1,
      },
    };
  } catch (error) {
    // Handle any errors that occur during the database operation
    console.error(error);
    throw new Error('An error occurred while executing the post-login action.');
  } finally {
    // Close the database connection
    connection.close();
  }
};

Error:
{
  "code": 400,
  "details": "",
  "error": "Cannot find module 'node-adodb'\nRequire stack:\n- /data/io/node16/58e77637-ae5b-4ae5-b1d5-7955db88cd1d/webtask.js",
  "message": "Compilation failed: Cannot find module 'node-adodb'\nRequire stack:\n- /data/io/node16/58e77637-ae5b-4ae5-b1d5-7955db88cd1d/webtask.js",
  "name": ""
}

when add the dependency on test as :
node-adodb@latest

it gives error as :
image

Hi @mmdanish,

Unfortunately, the node-adodb module is not one of the available modules that you can use.

For the full list of available modules, please see: Can I require? - Search which node modules you can use in webtask.io

Thanks,
Rueben

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.