Skip to content

Fix: auth controller duplicate code - #868

Merged
Nitya-003 merged 2 commits into
Nitya-003:mainfrom
Kirtan-pc:fix/auth-controller-duplicate-code
Jul 29, 2026
Merged

Fix: auth controller duplicate code#868
Nitya-003 merged 2 commits into
Nitya-003:mainfrom
Kirtan-pc:fix/auth-controller-duplicate-code

Conversation

@Kirtan-pc

Copy link
Copy Markdown
Contributor

📌 Overview

This PR fixes the badly merged backend/controllers/authController.js which had fully duplicated imports (lines 1-14 and 15-27), duplicate schema definitions producing unreachable dead code (lines 88-112), a duplicate sanitizeUser helper (lines 152-158 vs 159-165) where the second version returned raw user.balance instead of toNumber(user.balance || 0), and a duplicate resetPassword function (lines 880-928 vs 929-1019) where the second version used a weaker password.length < 8 string-length check instead of the proper Zod passwordSchema.

🛠️ Type of Change

  • ⛓️ Smart Contract (Solidity changes, Gas optimization)
  • 💻 Frontend (UI/UX, React components, Tailwind)
  • ⚙️ Backend (API routes, MongoDB schemas, Middleware)
  • 📄 Documentation (README, Roadmap updates)
  • 🧪 Testing (Hardhat tests, Jest/Vitest)

🔗 Related Issue

Closes #829


🧪 Testing & Verification

  • Smart Contracts: npx hardhat test passed? (Yes/No/NA)
  • Frontend: Verified on Mobile/Desktop responsiveness? (Yes/No/NA)
  • Integration: Verified authController.js loads without syntax errors and uses Zod validation consistently

📸 Screenshots / Demos

N/A


✅ PR Checklist

  • My code follows the project's style guidelines.
  • I have commented my code, particularly in complex areas (e.g., Smart Contract logic).
  • I have updated the documentation accordingly.
  • My changes generate no new warnings.

💬 Additional Notes

The corruption was introduced by a merge that duplicated every code block in the file. The second resetPassword silently overrode the first, using password.length < 8 instead of the Zod schema with full character-class requirements (uppercase, lowercase, digit, special char). Similarly, the second sanitizeUser overrode the first and returned raw Number balance instead of the toNumber()-converted value. All duplicate blocks have been removed and the single remaining implementations use consistent validation and Decimal128 handling.

…auction controller and related files

The auctionController.js file was corrupted with duplicate imports (lines 111-118)
and a duplicate createAuction function declaration causing SyntaxError. The same
corruption pattern affected authController.js, batchController.js, Auction.js,
Bid.js, and User.js - each had duplicate imports, duplicate schema/function
definitions, and improperly closed blocks.

This fix removes all duplicated code blocks, properly closes all functions,
and fixes Decimal128 handling in authController's addFunds function.
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

@Kirtan-pc is attempting to deploy a commit to the Nitya Gosain's projects Team on Vercel.

A member of the Team first needs to authorize it.

@Nitya-003 Nitya-003 added bug Something isn't working gssoc:approved gssoc'26 approved level:intermediate 35 pts for contributor 20 pts for mentor quality:exceptional *1.5 points for contributor +10 points for mentor type:bug labels Jul 29, 2026
@Nitya-003
Nitya-003 merged commit 83a7515 into Nitya-003:main Jul 29, 2026
6 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working gssoc:approved gssoc'26 approved level:intermediate 35 pts for contributor 20 pts for mentor quality:exceptional *1.5 points for contributor +10 points for mentor type:bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Corrupted authController.js has duplicate functions with weaker validation

2 participants