Skip to content

Commit

Permalink
Merge pull request #869 from bounswe/backend/profile
Browse files Browse the repository at this point in the history
handled same username case on edit profile
  • Loading branch information
halisbal authored Nov 26, 2023
2 parents 267b68a + 5c6f8e7 commit 7079ec8
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public Profile editProfile(String id, EditProfileRequestDto request, User user)

Profile editedProfile = profile.get();

if (request.getUsername() != null && !request.getUsername().isEmpty()) {
if (request.getUsername() != null && !request.getUsername().isEmpty() && !request.getUsername().equals(user.getUsername())) {
Optional<User> userToUpdate = userRepository.findByUsername(request.getUsername());
if (userToUpdate.isPresent()) {
throw new BadRequestException("Requested username is not available.");
Expand Down

0 comments on commit 7079ec8

Please sign in to comment.