diff --git a/apps/backend/src/app/api/v1/users/crud.tsx b/apps/backend/src/app/api/v1/users/crud.tsx index 9e0752020..ef4044809 100644 --- a/apps/backend/src/app/api/v1/users/crud.tsx +++ b/apps/backend/src/app/api/v1/users/crud.tsx @@ -22,33 +22,14 @@ export const userFullInclude = { providerConfig: true, }, }, - contactChannels: true, authMethods: { include: { passwordAuthMethod: true, otpAuthMethod: true, - oauthAuthMethod: { - include: { - oauthProviderConfig: { - include: { - proxiedOAuthConfig: true, - standardOAuthConfig: true, - }, - } - } - }, - } - }, - connectedAccounts: { - include: { - oauthProviderConfig: { - include: { - proxiedOAuthConfig: true, - standardOAuthConfig: true, - }, - } + oauthAuthMethod: true, } }, + contactChannels: true, teamMembers: { include: { team: true, @@ -105,8 +86,6 @@ export const userPrismaToCrud = ( throw new StackAssertionError("User cannot have more than one selected team; this should never happen"); } - const contactChannels = prisma.contactChannels.map(c => contactChannelToCrud(c)); - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition const primaryEmailContactChannel = prisma.contactChannels.find((c) => c.type === 'EMAIL' && c.isPrimary); const passwordAuth = prisma.authMethods.find((m) => m.passwordAuthMethod); @@ -133,7 +112,6 @@ export const userPrismaToCrud = ( selected_team_id: selectedTeamMembers[0]?.teamId ?? null, selected_team: selectedTeamMembers[0] ? teamPrismaToCrud(selectedTeamMembers[0]?.team) : null, last_active_at_millis: lastActiveAtMillis, - contact_channels: contactChannels, }; }; diff --git a/apps/e2e/tests/backend/endpoints/api/v1/auth/password/sign-in.test.ts b/apps/e2e/tests/backend/endpoints/api/v1/auth/password/sign-in.test.ts index 2b01de582..f52ea9507 100644 --- a/apps/e2e/tests/backend/endpoints/api/v1/auth/password/sign-in.test.ts +++ b/apps/e2e/tests/backend/endpoints/api/v1/auth/password/sign-in.test.ts @@ -41,6 +41,7 @@ it("should allow signing in to existing accounts", async ({ expect }) => { } `); }); +// TODO: check auth methods it("should not allow signing in with an e-mail that never signed up", async ({ expect }) => { const response = await niceBackendFetch("/api/v1/auth/password/sign-in", { diff --git a/apps/e2e/tests/backend/endpoints/api/v1/team-memberships.test.ts b/apps/e2e/tests/backend/endpoints/api/v1/team-memberships.test.ts index 212373b7c..f247e4753 100644 --- a/apps/e2e/tests/backend/endpoints/api/v1/team-memberships.test.ts +++ b/apps/e2e/tests/backend/endpoints/api/v1/team-memberships.test.ts @@ -71,16 +71,6 @@ it("creates a team and manage users on the server", async ({ expect }) => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": false, "id": "", @@ -99,16 +89,6 @@ it("creates a team and manage users on the server", async ({ expect }) => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": false, "id": "", @@ -157,16 +137,6 @@ it("creates a team and manage users on the server", async ({ expect }) => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": false, "id": "", diff --git a/apps/e2e/tests/backend/endpoints/api/v1/users.test.ts b/apps/e2e/tests/backend/endpoints/api/v1/users.test.ts index 7de64bb9f..fab2c061f 100644 --- a/apps/e2e/tests/backend/endpoints/api/v1/users.test.ts +++ b/apps/e2e/tests/backend/endpoints/api/v1/users.test.ts @@ -615,16 +615,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": false, "id": "", @@ -660,16 +650,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": "John Doe", "has_password": false, "id": "", @@ -721,16 +701,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": false, "id": "", @@ -771,16 +741,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": false, "id": "", @@ -814,7 +774,6 @@ describe("with server access", () => { "auth_with_email": false, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [], "display_name": null, "has_password": false, "id": "", @@ -852,16 +811,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": false, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": "John Dough", "has_password": false, "id": "", @@ -899,16 +848,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": false, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": true, "id": "", @@ -991,16 +930,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": false, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": false, "id": "", @@ -1056,16 +985,6 @@ describe("with server access", () => { "auth_with_email": false, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": false, - "type": "email", - "used_for_auth": false, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": false, "id": "", @@ -1100,16 +1019,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": false, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": true, "id": "", @@ -1159,16 +1068,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": false, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": true, "id": "", @@ -1200,16 +1099,6 @@ describe("with server access", () => { "auth_with_email": false, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": false, - "type": "email", - "used_for_auth": false, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": false, "id": "", @@ -1265,16 +1154,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": "John Doe", "has_password": false, "id": "", @@ -1302,16 +1181,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": "John Doe", "has_password": false, "id": "", @@ -1348,16 +1217,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": "John Doe", "has_password": false, "id": "", @@ -1394,16 +1253,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": true, "id": "", @@ -1489,16 +1338,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": { "key": "client value" }, "client_read_only_metadata": { "key": "client read only value" }, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": true, - "value": "@stack-generated.example.com", - }, - ], "display_name": null, "has_password": false, "id": "", @@ -1546,16 +1385,6 @@ describe("with server access", () => { "auth_with_email": true, "client_metadata": null, "client_read_only_metadata": null, - "contact_channels": [ - { - "id": "", - "is_primary": true, - "is_verified": true, - "type": "email", - "used_for_auth": false, - "value": "new-primary-email@example.com", - }, - ], "display_name": null, "has_password": false, "id": "", diff --git a/packages/stack-shared/src/interface/crud/users.ts b/packages/stack-shared/src/interface/crud/users.ts index c499ead6b..c4a741da1 100644 --- a/packages/stack-shared/src/interface/crud/users.ts +++ b/packages/stack-shared/src/interface/crud/users.ts @@ -17,15 +17,6 @@ export const usersCrudServerUpdateSchema = fieldSchema.yupObject({ selected_team_id: fieldSchema.selectedTeamIdSchema.nullable().optional(), }).required(); -const contactChannelSchema = fieldSchema.yupObject({ - id: fieldSchema.yupString().required(), - type: fieldSchema.yupString().required(), - value: fieldSchema.yupString().required(), - is_primary: fieldSchema.yupBoolean().required(), - is_verified: fieldSchema.yupBoolean().required(), - used_for_auth: fieldSchema.yupBoolean().required(), -}).required(); - export const usersCrudServerReadSchema = fieldSchema.yupObject({ id: fieldSchema.userIdSchema.required(), primary_email: fieldSchema.primaryEmailSchema.nullable().defined(), @@ -40,7 +31,6 @@ export const usersCrudServerReadSchema = fieldSchema.yupObject({ client_read_only_metadata: fieldSchema.userClientReadOnlyMetadataSchema, server_metadata: fieldSchema.userServerMetadataSchema, last_active_at_millis: fieldSchema.userLastActiveAtMillisSchema.required(), - contact_channels: fieldSchema.yupArray(contactChannelSchema).required(), oauth_providers: fieldSchema.yupArray(fieldSchema.yupObject({ id: fieldSchema.yupString().required(),