diff --git a/src/core/server/app/handlers/api/auth/local/signup.ts b/src/core/server/app/handlers/api/auth/local/signup.ts index 8703f6e7c1..8fa2960727 100644 --- a/src/core/server/app/handlers/api/auth/local/signup.ts +++ b/src/core/server/app/handlers/api/auth/local/signup.ts @@ -10,9 +10,10 @@ import { UsernameAlreadyExists, } from "coral-server/errors"; import { hasEnabledAuthIntegration } from "coral-server/models/tenant"; -import { LocalProfile, User } from "coral-server/models/user"; +import { LocalProfile, premodUser, User } from "coral-server/models/user"; import { create, usernameAlreadyExists } from "coral-server/services/users"; import { sendConfirmationEmail } from "coral-server/services/users/auth"; +import { shouldPremodDueToLikelySpamEmail } from "coral-server/services/users/emailPremodFilter"; import { RequestHandler, TenantCoralRequest } from "coral-server/types/express"; import { GQLUSER_ROLE } from "coral-server/graph/schema/__generated__/types"; @@ -117,6 +118,10 @@ export const signupHandler = ({ now ); + if (shouldPremodDueToLikelySpamEmail(tenant, user)) { + await premodUser(mongo, tenant.id, user.id); + } + // Send off to the passport handler. return handleSuccessfulLogin(user, signingConfig, req, res, next); } catch (err) { diff --git a/src/core/server/services/users/user.emailPremodFilter.spec.ts b/src/core/server/services/users/user.emailPremodFilter.spec.ts index 1af1fc42b9..2f17a6fd5e 100644 --- a/src/core/server/services/users/user.emailPremodFilter.spec.ts +++ b/src/core/server/services/users/user.emailPremodFilter.spec.ts @@ -3,8 +3,6 @@ import { createUserFixture, } from "coral-server/test/fixtures"; -import { GQLFEATURE_FLAG } from "coral-server/graph/schema/__generated__/types"; - import { EMAIL_PREMOD_FILTER_PERIOD_LIMIT, shouldPremodDueToLikelySpamEmail, @@ -14,9 +12,13 @@ const tooManyPeriodsEmail = "this.has.too.many.periods@test.com"; const justEnoughPeriodsEmail = "just.enough.periods@test.com"; const noPeriodsEmail = "noperiodshere@test.com"; -it("does not premod filter emails when feature flag is disabled", () => { +it("does not premod filter emails when feature is disabled", () => { const tenant = createTenantFixture({ - featureFlags: [], + premoderateEmailAddress: { + tooManyPeriods: { + enabled: false, + }, + }, }); const user = createUserFixture({ @@ -27,9 +29,13 @@ it("does not premod filter emails when feature flag is disabled", () => { expect(!result); }); -it(`does not premod filter emails when feature flag enabled and has less than ${EMAIL_PREMOD_FILTER_PERIOD_LIMIT} periods`, () => { +it(`does not premod filter emails when feature enabled and has less than ${EMAIL_PREMOD_FILTER_PERIOD_LIMIT} periods`, () => { const tenant = createTenantFixture({ - featureFlags: [GQLFEATURE_FLAG.EMAIL_PREMOD_FILTER], + premoderateEmailAddress: { + tooManyPeriods: { + enabled: true, + }, + }, }); const user = createUserFixture({ @@ -40,9 +46,13 @@ it(`does not premod filter emails when feature flag enabled and has less than ${ expect(result); }); -it(`does not premod filter emails when feature flag enabled and has no periods`, () => { +it(`does not premod filter emails when feature enabled and has no periods`, () => { const tenant = createTenantFixture({ - featureFlags: [GQLFEATURE_FLAG.EMAIL_PREMOD_FILTER], + premoderateEmailAddress: { + tooManyPeriods: { + enabled: true, + }, + }, }); const user = createUserFixture({ @@ -53,9 +63,13 @@ it(`does not premod filter emails when feature flag enabled and has no periods`, expect(result); }); -it(`does premod filter emails when feature flag is enabled and has too many (${EMAIL_PREMOD_FILTER_PERIOD_LIMIT} or more) periods`, () => { +it(`does premod filter emails when feature is enabled and has too many (${EMAIL_PREMOD_FILTER_PERIOD_LIMIT} or more) periods`, () => { const tenant = createTenantFixture({ - featureFlags: [GQLFEATURE_FLAG.EMAIL_PREMOD_FILTER], + premoderateEmailAddress: { + tooManyPeriods: { + enabled: true, + }, + }, }); const user = createUserFixture({