-
-
Notifications
You must be signed in to change notification settings - Fork 456
Add Rest endpoint to check if email exists #930
Add Rest endpoint to check if email exists #930
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding this endpoint! Could you also please write some tests for this (check that we return 200 OK on success and 404 on failure)?
Hi @knjk04, for some reasons MockMvc is not working, it is blocking me from writing test, could you help regarding the same? |
Hi @kuruvasatya, sure. I can help you with this. How come you closed this pull request? |
Hey @knjk04, that was by mistake, i am able to test the service, but for testing controller I think we need MockMvc, that seems to be not working, please help me |
Hey @knjk04 any Updates, its been days |
@@ -88,6 +90,16 @@ public User getUser(@PathVariable Long id) { | |||
); | |||
} | |||
|
|||
@GetMapping("/email/{email}") | |||
public ResponseEntity<String> checkIfEmailExists(@PathVariable String email) { | |||
Optional<User> user = userService.findUserByEmail(email); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userService.findUserByEmail(email)
.map(user-> ResponseEntity.ok())
.orElse(ResponseEntity.status(HttpStatus.NOT_FOUND).body(EMAIL_NOT_FOUND));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mslowiak I don't think that'll work:
Hi @kuruvasatya, so sorry for the delay & thanks for chasing up. I didn't get a chance to implement this, but I'll do it now. |
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Summary of change
Added new rest endpoint in the UserController.java class to check if email exists or not
Related issue
Closes #925
Pull request checklist
Please keep this checklist in & ensure you have done the following:
Read, understood and adhered to our contributing document.
Read, understood and adhered to our style guide. A lot of our code reviews are spent on ensuring compliance with our style guide, so it would save a lot of time if this was adhered to from the outset.
Set this pull request to 'draft' if you are still working on it
Resolved any merge conflicts
Filled in the summary, context (if applicable) and related issue section. Replace the square brackets and its placeholder content with your contents. For an example, see any merged in pull request
For any of the optional checkboxes (e.g. the screenshots one), still check it if it does not apply.