quash-max icon indicating copy to clipboard operation
quash-max copied to clipboard

Fix #20: Revamp User Controller

Open JishnuGoyal opened this issue 10 months ago โ€ข 4 comments

Quash Pull Request

Description

This pull request refactors the UserController by replacing the use of authentication.isAuthenticated() with exception handling using try-catch blocks. The goal is to enhance the robustness and stability of the controller by ensuring proper handling of potential authentication-related errors.

Fixes #20

Type of Change

Please check the relevant option(s)

  • [x] ๐Ÿ› Bug fix (non-breaking change addressing an issue)
  • [ ] โœจ New feature (non-breaking change adding functionality)
  • [ ] ๐Ÿ’ฅ Breaking change (fix or feature causing existing functionality to not work as expected)
  • [ ] ๐Ÿ“š Documentation update
  • [x] ๐Ÿงน Code refactor
  • [ ] ๐Ÿ”ง Build configuration change
  • [ ] โšก Performance improvement
  • [ ] ๐Ÿงช Test update

Component

Please check the relevant option(s)

  • [ ] ๐Ÿ“ฑ Android SDK
  • [x] ๐Ÿ–ฅ๏ธ Backend
  • [ ] ๐ŸŒ Frontend
  • [ ] ๐Ÿ”„ Cross-component change

Changes Made

Provide a bullet-point list of the key changes made in this PR

  • Replaced the existing logic that relied on authentication.isAuthenticated() with try-catch blocks.
  • Added NullPointerException to handle cases where the authentication object might be null.
  • A general Exception catch block is added to handle any other unexpected errors.
  • When exceptions are caught, appropriate error messages are returned to the client, with specific HTTP status codes (e.g., UNAUTHORIZED, INTERNAL_SERVER_ERROR).

How Has This Been Tested?

Describe the tests you ran to verify your changes. Provide instructions to reproduce and list any relevant details for your test configuration.

  • [ ] Unit tests
  • [ ] Integration tests
  • [ ] Manual tests

Test Configuration:

  • Quash SDK Version:
  • Device/Environment:
  • OS Version:
  • Backend Version (if applicable):
  • Frontend Version (if applicable):

Checklist

Please check all applicable items

  • [ ] My code follows the style guidelines of this project
  • [x] I have performed a self-review of my code
  • [ ] I have commented my code, particularly in complex areas
  • [ ] I have updated the documentation accordingly
  • [ ] My changes generate no new warnings or errors
  • [ ] I have added tests that prove my fix is effective or that my feature works
  • [ ] New and existing unit tests pass locally with my changes
  • [ ] Any dependent changes have been merged and published in downstream modules
  • [x] I have checked my code and corrected any misspellings

Additional Notes

Please review the changes and provide feedback. This refactor should not affect the functionality of the controller but is intended to make the code more robust and maintainable.

Screenshots (if appropriate)

If your changes include visual updates, please add before/after screenshots here.

JishnuGoyal avatar Sep 01 '24 16:09 JishnuGoyal