Skip to content

🧹 [code health] Refactor monolithic Auth controller method logic by extracting cookie helpers#20

Open
Adityavanjre wants to merge 3 commits into
mainfrom
refactor/auth-cookie-helpers-9033528662927682081
Open

🧹 [code health] Refactor monolithic Auth controller method logic by extracting cookie helpers#20
Adityavanjre wants to merge 3 commits into
mainfrom
refactor/auth-cookie-helpers-9033528662927682081

Conversation

@Adityavanjre

@Adityavanjre Adityavanjre commented May 8, 2026

Copy link
Copy Markdown
Owner

🎯 What: Extracted response cookie settings into an auth helper module.
💡 Why: Centralizes the core authentication cookie management logic, making the AuthController less monolithic and the cookie setup logic reusable and easier to test independently. This improves code health and maintainability.
Verification: Verified by ensuring the code logic is 1:1 with previous execution, running the test suite to ensure no tests regressed, and validating with code review tooling.
Result: A highly modular, cleaner auth.controller.ts with no behavioral changes.


PR created automatically by Jules for task 9033528662927682081 started by @Adityavanjre

Summary by CodeRabbit

  • Refactor
    • Reorganized authentication cookie management to centralize handling and ensure consistent security practices across login, logout, and token refresh flows.

Extracts the monolithic cookie handling in `nexus/backend/src/auth/auth.controller.ts` into a dedicated `auth/helpers/cookie.helper.ts` module, exposing `setAuthCookies` and `clearAuthCookies`. This improves modularity and cleans up the controller logic.

Co-authored-by: Adityavanjre <66417028+Adityavanjre@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented May 8, 2026

Copy link
Copy Markdown

Review Change Stack

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Free

Run ID: 50ab29c5-fb51-4558-91e7-d8bfa1b0f9fa

📥 Commits

Reviewing files that changed from the base of the PR and between 6051811 and e082bfc.

📒 Files selected for processing (2)
  • nexus/backend/src/auth/auth.controller.ts
  • nexus/backend/src/auth/helpers/cookie.helper.ts

📝 Walkthrough

Walkthrough

This PR refactors authentication cookie management by extracting cookie-setting and cookie-clearing logic from the auth controller into a reusable helper module. The helper centralizes CSRF token generation and cookie attribute configuration, while the controller now delegates all cookie operations to these shared functions across login, registration, MFA, refresh, and logout flows.

Changes

Auth Cookie Helper Extraction

Layer / File(s) Summary
Cookie Helper Functions
nexus/backend/src/auth/helpers/cookie.helper.ts
New setAuthCookies function sets nexus_token (HTTP-only, 1d), optional nexus_refresh (HTTP-only, 7d), and CSRF nexus-csrf (non-HTTP-only, 1d). New clearAuthCookies clears token and refresh cookies.
Controller Integration
nexus/backend/src/auth/auth.controller.ts
Auth controller imports helpers and replaces all internal cookie-setting calls across login, register, MFA, refresh endpoints with setAuthCookies(...) and logout with clearAuthCookies(res). Internal setAuthCookies implementation removed.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes


Note

🎁 Summarized by CodeRabbit Free

Your organization is on the Free plan. CodeRabbit will generate a high-level summary and a walkthrough for each pull request. For a comprehensive line-by-line review, please upgrade your subscription to CodeRabbit Pro by visiting https://app.coderabbit.ai/login.

Comment @coderabbitai help to get the list of available commands and usage tips.

…flict

Extracts the monolithic cookie handling in `nexus/backend/src/auth/auth.controller.ts` into a dedicated `auth/helpers/cookie.helper.ts` module, exposing `setAuthCookies` and `clearAuthCookies`. This improves modularity and cleans up the controller logic.

Also fixes a CI failure where `ajv` version `^6.12.6` was causing `npx nest build` to fail by updating the `package.json` override for `ajv` to `^8.18.0` as indicated in repository memory.

Co-authored-by: Adityavanjre <66417028+Adityavanjre@users.noreply.github.com>
@Adityavanjre Adityavanjre reopened this May 8, 2026
Extracts the monolithic cookie handling in `nexus/backend/src/auth/auth.controller.ts` into a dedicated `auth/helpers/cookie.helper.ts` module, exposing `setAuthCookies` and `clearAuthCookies`. This improves modularity and cleans up the controller logic.

Co-authored-by: Adityavanjre <66417028+Adityavanjre@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant