Skip to content

Commit

Permalink
fix #13
Browse files Browse the repository at this point in the history
  • Loading branch information
arthurgregorio committed Apr 24, 2018
1 parent a6a37ee commit 5f3735e
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ public User save(User user) {
public void update(User user) {

// validate the email
final Optional<User> emailOptional = this.userRepository
final Optional<User> userOptional = this.userRepository
.findOptionalByEmail(user.getEmail());

if (emailOptional.isPresent()) {
if (userOptional.isPresent()) {

final User found = emailOptional.get();
final User found = userOptional.get();

if (!found.getUsername().equals(user.getUsername())) {
throw new BusinessLogicException("user.email-duplicated");
Expand All @@ -116,6 +116,8 @@ public void update(User user) {
// crypt the user password
user.setPassword(this.passwordEncoder.encryptPassword(
user.getPassword()));
} else {
user.setPassword(userOptional.get().getPassword());
}
}

Expand Down

0 comments on commit 5f3735e

Please sign in to comment.