Hi everyone,
In the migration process from the rules to the new actions, I’ve found out that I cannot specify the error thrown to the user but I can only set the message. The two pieces of code are the following:
Action:
exports.onExecutePostLogin = async (event, api) => {
if (!event.user.email_verified) {
api.access.deny("Please verify your email before logging in.");
};
}
Rule:
function (user, context, callback) {
if (!user.email_verified) {
return callback(new UnauthorizedError('Please verify your email before logging in.'));
} else {
return callback(null, user, context);
}
}
The result of the action is:
{
"error": "access_denied",
"error_description": "Please verify your email before logging in."
}
The result of the rule is:
{
"error": "unauthorized",
"error_description": "Please verify your email before logging in."
}
My frontend application relies on the error
field to show the corresponding error in various other languages and now I will need to update the error map to accept the “access_denied” string as a valid error and not show the default error.
We don’t have the API to change that “error” field, is this by design or it will be implemented in the future? Is there a plan to support this or for now we either need to deploy our FE or use the old rule as long as actions will support the legacy rules?