Fix user login: seed script for sample_mflix passwords#5
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
Fix user login: seed script for sample_mflix passwords#5devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
…odology Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
Test Results: Random Password Seeding & LoginTested by: Devin — ran the app locally against the remote MongoDB Atlas database, tested login flow end-to-end with unique random passwords from credentials.csv. Test 1: Login with correct random password — PASSED
Test 2: Old shared password "password" rejected — PASSED
Test 3: Another user's password rejected (proves uniqueness) — PASSED
Summary: All 3 tests passed. Each user has a unique random password. Old shared password rejected. Bcrypt (12 rounds) working correctly. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
sample_mflix.userscollection had bcrypt-hashed passwords from MongoDB's sample dataset with unknown plaintext values, making login impossible.Fix:
buildScripts/seedPasswords.jsto generate a unique random 16-character password per user usingcrypto.randomBytes()(CSPRNG), hash it with bcrypt (12 rounds), and store only the hash in the databaseemail,name,password) — redirect to a file to save themREADME.mdwith:Review & Testing Checklist for Human
MONGODB_URI=... npx babel-node buildScripts/seedPasswords.js > credentials.csvto generate fresh passwordscredentials.csvand pick a user — log in at/loginwith their email and passwordNotes
crypto.randomBytes(12)— high entropyconsole.logfor CSV data (stdout) andconsole.errorfor status messages (stderr), so> credentials.csvcaptures only the credentialsLink to Devin session: https://app.devin.ai/sessions/0d833d4d3ece4b3eb062814e69f69c0d
Requested by: @abalaster