Remove attributes from user rule template migration to login flow action script not working

Hi Auth0 Community

I successfully created a rule based on the Remove attributes from user template

function removeUserAttribute(user, context, callback) {
  const blacklist = ['nickname','picture'];

  Object.keys(user).forEach(function (key) {
    if (blacklist.indexOf(key) > -1) {
      delete user[key];
    }
  });

  callback(null, user, context);
}

I migrated the code to a Login Flow action script.

exports.onExecutePostLogin = async (event, api) => {
  const blacklist = ['nickname','picture'];

  Object.keys(event.user).forEach(function (key) {
    if (blacklist.indexOf(key) > -1) {
      delete event.user[key]; 
    }
  });

  return;

};

The rule works, but the action script doesn’t. What have I done wrong?

Kind regards

Richard

Hi All

I created a support ticket and received this response.

It’s currently not possible to remove claims from the ID token using actions. It’s on our roadmap to close this parity gap but it likely won’t be supported until later next year.

So I will keep the working rule and be patient :grin:

Regards

Richard

1 Like

Thanks for sharing it with the rest of community!