Set up custom data only once

I am using email/password as my authentication provider for my realm web project., and my current user is null until my user is confirmed by logging in. It is at that point that my custom data object is setup. The issue is that now, my custom data object is set up each time my user logs in. How can I, for example, setup custom data on sign up, or ensure that it is setup only once? I am considering on signup, because that is certainly only going to happen once. Is there some aggregation I might use, any help would be appreciated

Upon log in, read the custom user datra

if it doesn’t exist, set it up.

If it does exist, leave it alone?

That can be done by calling the function to refresh the user data (In Swift: user.refreshCustomData) or just attempting to read that data, and if it fails, that data doesn’t exist.