-
Notifications
You must be signed in to change notification settings - Fork 514
Enhance sign-up rules with derived country code and risk score handling #1232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
14f5b22
COUNTRY CODE (1)
mantrakp04 fb315a9
Enhance sign-up rules with derived country code and risk score handli…
mantrakp04 26b3506
Refactor country code handling across the application. Introduced a c…
mantrakp04 7e258d7
Refactor sign-up country code handling to derive only from request ge…
mantrakp04 5250595
Refactor country code validation by introducing a centralized `validC…
mantrakp04 ebbfa47
Enhance `getDerivedSignUpCountryCode` function to support email-based…
mantrakp04 cabefdd
Refactor user schema to centralize metadata for admin restrictions an…
mantrakp04 33dd37a
Add KMS script to package.json for managing port processes
mantrakp04 23bd2aa
Implement country code selection component in sign-up rules and updat…
mantrakp04 6db97e7
Update user test cases to include country_code and risk_scores fields…
mantrakp04 7de1a49
Update user and OAuth test cases to include country_code and risk_sco…
mantrakp04 180c1a7
Update team membership and user tests to reflect changes in response …
mantrakp04 0b962fe
Enhance CEL expression evaluation tests for country code handling. Ad…
mantrakp04 bd51d88
Refactor user creation logic to improve handling of restricted user a…
mantrakp04 1257021
Merge branch 'fraud-protection' into fraud-protection-country-code
mantrakp04 9c5eda1
Merge branch 'fraud-protection' into fraud-protection-country-code
mantrakp04 7d42522
Merge branch 'fraud-protection' into fraud-protection-country-code
mantrakp04 5e4da43
Merge branch 'fraud-protection' into fraud-protection-country-code
mantrakp04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
apps/backend/prisma/migrations/20260309000000_add_project_user_country_code/migration.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| -- Add nullable sign-up country code to ProjectUser | ||
| ALTER TABLE "ProjectUser" ADD COLUMN "countryCode" TEXT; |
48 changes: 48 additions & 0 deletions
48
...kend/prisma/migrations/20260309000000_add_project_user_country_code/tests/default-null.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { randomUUID } from 'crypto'; | ||
| import type { Sql } from 'postgres'; | ||
| import { expect } from 'vitest'; | ||
|
|
||
| export const preMigration = async (sql: Sql) => { | ||
| const projectId = `test-${randomUUID()}`; | ||
| const tenancyId = randomUUID(); | ||
| const userId = randomUUID(); | ||
|
|
||
| await sql`INSERT INTO "Project" ("id", "createdAt", "updatedAt", "displayName", "description", "isProductionMode") VALUES (${projectId}, NOW(), NOW(), 'Test', '', false)`; | ||
| await sql`INSERT INTO "Tenancy" ("id", "createdAt", "updatedAt", "projectId", "branchId", "hasNoOrganization") VALUES (${tenancyId}::uuid, NOW(), NOW(), ${projectId}, 'main', 'TRUE'::"BooleanTrue")`; | ||
| await sql` | ||
| INSERT INTO "ProjectUser" ( | ||
| "projectUserId", | ||
| "tenancyId", | ||
| "mirroredProjectId", | ||
| "mirroredBranchId", | ||
| "createdAt", | ||
| "updatedAt", | ||
| "lastActiveAt", | ||
| "signUpRiskScoreBot", | ||
| "signUpRiskScoreFreeTrialAbuse" | ||
| ) VALUES ( | ||
| ${userId}::uuid, | ||
| ${tenancyId}::uuid, | ||
| ${projectId}, | ||
| 'main', | ||
| NOW(), | ||
| NOW(), | ||
| NOW(), | ||
| 0, | ||
| 0 | ||
| ) | ||
| `; | ||
|
|
||
| return { userId }; | ||
| }; | ||
|
|
||
| export const postMigration = async (sql: Sql, ctx: Awaited<ReturnType<typeof preMigration>>) => { | ||
| const rows = await sql` | ||
| SELECT "countryCode" | ||
| FROM "ProjectUser" | ||
| WHERE "projectUserId" = ${ctx.userId}::uuid | ||
| `; | ||
|
|
||
| expect(rows).toHaveLength(1); | ||
| expect(rows[0].countryCode).toBeNull(); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.