techcsispit / MERN-Auth-Workouts-App

This Workouts App is a full-stack CRUD application built using the MERN stack (MongoDB, Express, React, Node.js) with authentication implemented using Bcrypt and JWT. The app allows users to create, update, view, and delete workouts once they are authenticated. Contributions are welcome to improve styling, fix bugs, and add features.
0 stars 2 forks source link

Resolved Issue Inconsistent JWT Secret Variable Naming #1 #3

Closed Dash10107 closed 2 weeks ago

Dash10107 commented 2 weeks ago

This pull request resolves the issue of inconsistent naming for the JWT secret variable across the codebase. The .env file suggested using JWT_SECRET, but SECRET was used throughout the code. This PR ensures that the correct and consistent variable JWT_SECRET is used throughout the codebase.

Changes made: Replaced all instances of SECRET with JWT_SECRET in the code. Updated documentation to reflect the new variable name. Verified that the application functions correctly after the change.

Additional Changes: Frontend Proxy Update: The proxy setting in the frontend's package.json file was updated from:

"proxy": "http://localhost:4000", to: "proxy": "http://localhost:5000",

This change was made to match the correct backend port and avoid proxy issues during development.

UserModel Validation Fix:

In userModel, the password validation was mistakenly checking the strength of the email instead of the password. The code was:

if (!validator.isStrongPassword(email)) { and was updated to:

if (!validator.isStrongPassword(password)) { throw Error('Password not strong enough'); } This fixes email and password validation confusion to ensure proper security checks.

Issue reference: Resolves #1

Why this is important: This change ensures consistency in variable naming across the codebase, preventing potential bugs or confusion when configuring environment variables. It makes the configuration more intuitive and avoids errors during deployment or local development.