diff --git a/backend/api/src/create-profile.ts b/backend/api/src/create-profile.ts index 834de9f3..4c787884 100644 --- a/backend/api/src/create-profile.ts +++ b/backend/api/src/create-profile.ts @@ -15,11 +15,11 @@ import {getUser, log} from 'shared/utils' export const createProfile: APIHandler<'create-profile'> = async (body, auth) => { const pg = createSupabaseDirectClient() - const {data: existingUser} = await tryCatch( + const {data: existingProfile} = await tryCatch( pg.oneOrNone<{id: string}>('select id from profiles where user_id = $1', [auth.uid]), ) - if (existingUser) { - throw new APIError(400, 'User already exists') + if (existingProfile) { + throw new APIError(400, 'Profile already exists') } await removePinnedUrlFromPhotoUrls(body) diff --git a/backend/api/tests/unit/create-profile.unit.test.ts b/backend/api/tests/unit/create-profile.unit.test.ts index f1b83c05..95a09835 100644 --- a/backend/api/tests/unit/create-profile.unit.test.ts +++ b/backend/api/tests/unit/create-profile.unit.test.ts @@ -293,7 +293,7 @@ describe('createProfile', () => { ) }) - it('should throw if the user already exists', async () => { + it('should throw if the profile already exists', async () => { const mockBody = { city: 'mockCity', gender: 'mockGender', @@ -311,7 +311,7 @@ describe('createProfile', () => { ;(tryCatch as jest.Mock).mockResolvedValueOnce({data: true, error: null}) await expect(createProfile(mockBody, mockAuth, mockReq)).rejects.toThrowError( - 'User already exists', + 'Profile already exists', ) })