Identity and adding a user role when signing up

I am adding a new auth feature to the site I am building using react-netlify-identity

I have a signup page working and adding ‘full_name’, ‘email’ and the user is added to identity.

I am trying to set a role when the user signs up.

Is this possible?

I have tried passing the following data object but not having any luck as it adds the roles to the user_metadata and not the app_metadata which is where it should be.

    app_metadata: {
      'roles': ['Subscriber', 'Editor']
    },
    user_metadata: {
        'full_name':fullName
    }

This is what happens.

    app_metadata: {
        provider: "email"
    }
    aud: ""
    confirmation_sent_at: "2021-05-24T12:02:10Z"
    confirmed_at: "2021-05-24T12:02:25Z"
    created_at: "2021-05-24T12:02:10Z"
    email: "Alex@heriam.co.uk"
    id: "82dd9996-7766-4f24-9e29-540fc3e43b21"
    role: ""
    token: {,…}
    updated_at: "2021-05-24T12:02:10Z"
    url: "https://www.hereiam.com/.netlify/identity"
    user_metadata: {
        app_metadata: {
            roles: ["Subscriber", "Editor"]
        }, 
        user_metadata: {
            full_name: "Alex"
        }
    }

Any help or advice what I am doing wrong would be appreciated.

Basically, what you’re probably looking for is the identity-signup function mentioned here: Functions and Identity | Netlify Docs

Then, you can access and modify the app_metadata using the admin token and make changes as required. Sadly, the admin actions can’t be tested locally using CLI, so you’d have to publish the changes online to test.