A developer implemented a user login system across two files — auth.js and
login.js — but committed the changes in the wrong order. All the code is
already written and present in the repository. Your task is to reorder the
commits so that the implementation is logically correct.
-
Fork and clone this repository.
-
Run
git log --onelineto see the existing commits. -
Use
git rebase -ito reorder the commits into the correct logical sequence. -
During the rebase you may encounter merge conflicts. Read each conflict carefully and decide whether to keep the current change or accept the incoming change. Resolve every conflict, then run
git addandgit rebase --continue. -
Once the rebase is complete, run the test to verify your solution:
node test.jsAll tests must pass.
- Do not edit
test.js. - Do not add or delete any commits — only reorder them.
- The correct order is one where each commit logically builds on the previous one (e.g., you cannot use a function before it is defined).
- Conflict resolution should reflect the correct final behaviour of the system.
auth.js— core authentication utilities (hashing, token generation, validation)login.js— user-facing functions (register, login, logout)test.js— automated test runner, do not modify
node test.js
A passing run prints each test result and exits with code 0. A failing run exits with code 1.