Need help making this rule in actions

Hi, I found this post a few years ago.

It was the problem is what I was running into and this rule solved it. The problem is rules are going away and I can’t figure out how to convert it from the rule listed into an action. My feeble attempts have so far failed to net the same result.

Does anyone know how to take this rule:

function (user, context, callback) {
user.preferred_username = user.username;
return callback(null, user, context);
}

And make it an equally functional action that map to the OIDC claim of preferred_username to the username?

Any help is appreciated thanks

Well I think between me and an AI bot were able to come up with this after some creative prompting. After a few tests I am pretty sure it’s working as the old rule did.

So I’ll put it here for anyone else who finds the old rule post and is wondering how to do it in new actions.

exports.onExecutePostLogin = async (event, api) => {
// Set the preferred_username in the ID token
api.idToken.setCustomClaim(“preferred_username”, event.user.username);
};

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