Skip to content

feat(legal): add privacy_policy_accepted field to User and enforce on registration#53

Merged
vitorhugo-java merged 3 commits into
mainfrom
feat/privacy-policy
Jun 9, 2026
Merged

feat(legal): add privacy_policy_accepted field to User and enforce on registration#53
vitorhugo-java merged 3 commits into
mainfrom
feat/privacy-policy

Conversation

@vitorhugo-java

Copy link
Copy Markdown
Owner

Summary

  • Flyway V28 (V28__add_privacy_policy_accepted_to_users.sql): adds privacy_policy_accepted TINYINT(1) NOT NULL DEFAULT 0 and privacy_policy_accepted_at DATETIME NULL columns to the users table
  • User entity: two new fields with getters/setters
  • RegisterRequest: new acceptedPrivacyPolicy field annotated with @AssertTrue — returns HTTP 400 if the client sends false or omits the field
  • AuthService.register(): sets privacyPolicyAccepted = true and privacyPolicyAcceptedAt = now() when a user completes registration
  • UserResponse: exposes privacyPolicyAccepted so the frontend can read the flag
  • AuthMapper: maps the new field from entity to DTO

Why

Google requires every user to actively accept a Privacy Policy before an OAuth2 app can be approved for production. This change persists the acceptance event (boolean + timestamp) for compliance and audit purposes.

Reviewer notes

  • The DEFAULT 0 in the migration means all existing users will have privacy_policy_accepted = 0. That is intentional — existing users predate this requirement and can be handled separately if needed
  • The @AssertTrue constraint fires during Spring's @Valid processing on the controller, so no changes are needed in the controller itself
  • Frontend counterpart: vitorhugo-java/React-JobApplyTracker — PR adds the checkbox UI and sends the flag on registration

Test plan

  • Run the app — Flyway V28 migration applies cleanly with no errors
  • POST /api/v1/auth/register without acceptedPrivacyPolicy or with false → HTTP 400 with validation message
  • POST /api/v1/auth/register with acceptedPrivacyPolicy: true → HTTP 200, check DB row has privacy_policy_accepted = 1 and a non-null privacy_policy_accepted_at
  • GET /api/v1/auth/me returns privacyPolicyAccepted: true for newly registered user

🤖 Generated with Claude Code

… registration

Adds two columns to the users table (Flyway V28): privacy_policy_accepted
and privacy_policy_accepted_at. RegisterRequest now validates that the
client sends acceptedPrivacyPolicy=true (400 otherwise). AuthService sets
the flag and timestamp at registration time. UserResponse exposes the field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

Qodana for JVM

3 new problems were found

Inspection name Severity Problems
Nullability and data flow problems 🔶 Warning 1
Mismatched query and update of 'StringBuilder' 🔶 Warning 1
Simplifiable conditional expression 🔶 Warning 1
View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2025.3.2
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

@github-actions github-actions Bot added the tests label Jun 8, 2026
…ivacyPolicy in E2E tests

ToolExecutionMetric was using Lombok annotations (@Getter, @Setter, @builder) which
fail annotation processing under GraalVM/Java 25. Replaced with manual getters, setters,
and a static inner Builder following the existing codebase style.

E2E register payloads were missing the acceptedPrivacyPolicy field introduced in a recent
migration, causing all registration calls to return 400. Added acceptedPrivacyPolicy: true
to all affected test payloads in ApplicationE2ETest and AuthE2ETest.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vitorhugo-java vitorhugo-java merged commit affd0b8 into main Jun 9, 2026
6 checks passed
@vitorhugo-java vitorhugo-java deleted the feat/privacy-policy branch June 9, 2026 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant