Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User Settings Enhancements and user update/delete endpoints #41

Merged
merged 9 commits into from
May 16, 2024

Conversation

tristenwallace
Copy link
Owner

Overview

This pull request introduces several improvements to both the front-end and back-end of our application. The changes include new backend endpoints for updating and deleting user accounts, updates to the frontend API and components for user settings, navbar updates, and poll anonymization for deleted users.

Changes Summary

  1. Backend:

    • Added new endpoints for updating and deleting user accounts.
    • Implemented poll anonymization when a user deletes their account.
    • Enhanced user authentication middleware for better logging.
    • Updated database models and migrations to support poll anonymization.
  2. Frontend:

    • Created a new UserSettings component for updating user details and deleting accounts.
    • Updated the navbar to include a user profile dropdown with links to settings and logout.
    • Improved the API to handle user updates and deletions.
    • Implemented pagination for displaying user's polls in the settings page.

Detailed Changes

Backend:

  1. Controllers (userController.ts):

    • Added updateUser function for updating user details.
    • Added deleteUser function for deleting user accounts and anonymizing their polls.
    • Enhanced logging for better traceability.
  2. Routes (userRoutes.ts):

    • Added new routes for updating (PUT /user/:id) and deleting (DELETE /user/:id) user accounts.
    • Ensured authentication middleware is applied to these routes.
  3. Middleware (authenticate.ts):

    • Improved logging in the authentication middleware.
  4. Models (poll.ts):

    • Updated the Poll model to make userId nullable for anonymization.
  5. Migrations (20240422193909-create-polls.ts):

    • Modified poll creation migration to support nullable userId.
  6. API Documentation (API.md):

    • Updated to include the new user update and delete endpoints.

Frontend:

  1. Components (UserSettings.tsx):

    • Created a UserSettings component that allows users to update their name, password, and avatar URL, and delete their account.
    • Included detailed logging and form validation.
  2. API (api.ts):

    • Added functions for updating and deleting user accounts.
  3. Navbar (Navbar.tsx):

    • Updated the navbar to include a user profile dropdown with links to settings and logout.

Testing

  • Manual testing of user settings update and deletion functionality.
  • Verified that polls created by a deleted user are anonymized.
  • Ensured that the updated navbar displays the user profile dropdown correctly.

How to Test

  1. Backend:

    • Start the backend server: npm run dev.
    • Use Postman to test the new endpoints:
      • Update User: PUT http://localhost:5000/user/:id
      • Delete User: DELETE http://localhost:5000/user/:id
  2. Frontend:

    • Start the frontend server: npm start.
    • Navigate to the user settings page and test updating and deleting user details.
    • Verify the updated navbar functionality.

- Modified `API.md` to document new user update and delete endpoints.

- Enhanced `userController.ts` with detailed logging and improved user
    update and delete functionality.

- Updated poll migration (`20240422193909-create-polls.ts`) to support
    user anonymization on deletion.

- Adjusted `poll.ts` model to handle userId as nullable.

- Improved `authenticate.ts` middleware with additional logging for debugging.

- Updated `userRoutes.ts` to ensure proper authentication middleware
    application on update and delete endpoints.
@tristenwallace tristenwallace merged commit 436dd12 into main May 16, 2024
1 check passed
@tristenwallace tristenwallace deleted the user_settings branch May 16, 2024 22:59
@tristenwallace tristenwallace linked an issue May 16, 2024 that may be closed by this pull request
@tristenwallace
Copy link
Owner Author

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User Management Page and Poll Deletion
1 participant