divyansh-2005 / my-calendar-app

My Calendar App is a full-stack application designed to help users manage their schedules, expenses, todos, and notes all in one place. The app provides a seamless and intuitive user interface for efficient day-to-day management and includes robust backend support for secure data handling and user authentication.
https://my-calendar-app-phi.vercel.app
22 stars 51 forks source link

[BUG] Seperate Generate Token Function #81

Open lambeboluwatife opened 1 month ago

lambeboluwatife commented 1 month ago

Describe the bug The JWT is generated directly within the registerUser and login function using jwt.sign. However, it may be harder to maintain or reuse if you need the token generation logic in other application parts.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'the backend folder'
  2. Go to 'the controllers folder'
  3. Click on the 'authController'
  4. Scroll down to 'from line 37 - 54 and from line 79 - 94'
  5. See error

Expected behavior The token generation will by a separate generateToken function. The function will be async and can be awaited, allowing for a cleaner and more reusable approach. The function will be designed to handle the JWT creation and is abstracted away from the core logic.

Benefit: The separation of token generation into its own function (generateToken) makes the code modular and reusable. This function can be easily called in different parts of the application, making maintenance easier.

Screenshots before image

**screenshots after fix*** image

check list

Additional context @divyansh-2005 Assign to me