monorepo icon indicating copy to clipboard operation
monorepo copied to clipboard

Connect profile if exists after register

Open 7alip opened this issue 1 year ago • 0 comments

Describe the bug

We create a profile for each user after they register. Some profiles are created using a voluntary form with no user connection. If those volunteers try to register, user data is created, but profile creation fails due to the profile's unique email field. In this case, rather than attempting to create a new profile, we should connect the registered user to an existing one.

Solution

packages/services/src/api/register.ts.

    // Search if the profile exists with the registration email.
    // Use Mutation.put and connect profile with userId or the other way around
    // If the profile doesn't exist then create a new one
    await Mutation.post('profiles', body, response.data?.jwt)

7alip avatar May 22 '24 11:05 7alip