Skip to content

Refactor auth route registration complexity#324

Open
sandervonk wants to merge 1 commit into
mainfrom
svonk/task-1-context
Open

Refactor auth route registration complexity#324
sandervonk wants to merge 1 commit into
mainfrom
svonk/task-1-context

Conversation

@sandervonk

Copy link
Copy Markdown

GENERATED PR:

Summary

This PR refactors the authentication route setup to address the qlty smell for high function complexity in reloadRoutes.

Problem

The function reloadRoutes in src/routes/authentication.js had high cyclomatic complexity due to deeply nested strategy registration and callback handlers.

What Changed

  • Extracted local login strategy setup into a dedicated helper.
  • Extracted SSO strategy loading into a dedicated helper with error handling.
  • Extracted strategy auth route registration into a dedicated helper.
  • Extracted callback state validation into a dedicated helper.
  • Extracted strategy callback authentication flow into a dedicated helper.
  • Extracted successful login finalization into a dedicated helper.
  • Extracted base auth route registration for register/login/logout endpoints into a dedicated helper.
  • Reduced reloadRoutes to orchestration logic while preserving existing behavior.

Why This Helps

  • Lowers complexity in reloadRoutes and improves maintainability.
  • Makes the authentication flow easier to read and reason about.
  • Keeps behavior centralized but split into focused units.

Validation

  • Ran npm run test
  • Result: 4650 passing, 146 pending
  • Coverage summary generated successfully

Notes

  • No intended functional behavior changes, only structural refactoring to reduce complexity and improve readability.

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