Identity-signup seems to run successfully, but roles aren't set afterwards

We’ve been using Netlify identity for a long time now, didn’t have any recent changes with that part; But starting from the day before yesterday new signups don’t have any roles set. Is there a problem with the service itself?

We’re setting the roles by using this snippet: (roles is an array of roles with the expected values → verified by a console.log before the return statement.)

return {
            statusCode: 200,
            body: JSON.stringify({ app_metadata: { roles } }),
        };
1 Like

I think I might be having a similar issue, my identity-signup function isn’t updating app_metadata anymore but it had been working flawlessly for years.

Hi, can you provide a reproduction of this issue

Sure, the minimal use case seems to be an identity-signup function with this implementation:

import { Handler, HandlerEvent, HandlerContext } from "@netlify/functions";

const handler: Handler = async function (event: HandlerEvent, context: HandlerContext) {
  return {
    statusCode: 200,
    body: JSON.stringify({ app_metadata: {roles: ["test"] } }),
  };
};

export { handler };

My temporary workaround using the same callback function (identity-signup) that normally returns the users metadata. To set the metadata, I’m calling the admin endpoint with the supplied auth token.

// BEGIN this is currently the only way to set roles

        const identity = context.clientContext?.identity;

        if (identity) {
            return fetch(identity.url + "/admin/users/" + userInfo.id, {
                method: "PUT",
                body: JSON.stringify({
                    app_metadata: {
                        roles,
                    },
                }),
                headers: {
                    Authorization: "Bearer " + identity.token,
                },
            }).then(() => {
                console.info("roles set", roles);
                return {
                    statusCode: 200,
                    body: JSON.stringify({ app_metadata: { roles } }),
                };
            });
        } else {
            console.error("No identity in context", identity);

            return {
                statusCode: 500,
                body: `There was an error signing up user ${dto.user.id} `,
            };
        }

        // END this is currently the only way to set roles

@SamO
Do you need anything else to help you reproduce?

Hi @Shadowmap sorry for the delay we just filed an escalation and our devs rolled out a fix yesterday evening! Are you still experiencing this issue? If so please let us know and I can escalate.

Thanks, this seems to work again now.