This commit is contained in:
Mohamed Karray
2018-09-20 12:13:21 +02:00
parent b80e9666aa
commit 2683dd651b
4 changed files with 6 additions and 6 deletions

View File

@@ -2,7 +2,7 @@ package sonia.scm.user;
public class ChangePasswordNotAllowedException extends RuntimeException { public class ChangePasswordNotAllowedException extends RuntimeException {
public static final String WRON_USER_TYPE = "User of type {0} are not allowed to change password"; public static final String WRONG_USER_TYPE = "User of type {0} are not allowed to change password";
public ChangePasswordNotAllowedException(String message) { public ChangePasswordNotAllowedException(String message) {
super(message); super(message);

View File

@@ -2,7 +2,7 @@ package sonia.scm.user;
public class InvalidPasswordException extends RuntimeException { public class InvalidPasswordException extends RuntimeException {
public static final String PASSWORD_NOT_MATCHED = "The given Password does not match with the stored one."; public static final String PWD_NOT_MATCHED = "The given Password does not match with the stored one.";
public InvalidPasswordException(String message) { public InvalidPasswordException(String message) {
super(message); super(message);

View File

@@ -41,7 +41,7 @@ import sonia.scm.search.Searchable;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.util.function.Consumer; import java.util.function.Consumer;
import static sonia.scm.user.ChangePasswordNotAllowedException.WRON_USER_TYPE; import static sonia.scm.user.ChangePasswordNotAllowedException.WRONG_USER_TYPE;
/** /**
* The central class for managing {@link User} objects. * The central class for managing {@link User} objects.
@@ -81,7 +81,7 @@ public interface UserManager
default Consumer<User> getUserTypeChecker() { default Consumer<User> getUserTypeChecker() {
return user -> { return user -> {
if (!isTypeDefault(user)) { if (!isTypeDefault(user)) {
throw new ChangePasswordNotAllowedException(MessageFormat.format(WRON_USER_TYPE, user.getType())); throw new ChangePasswordNotAllowedException(MessageFormat.format(WRONG_USER_TYPE, user.getType()));
} }
}; };
} }

View File

@@ -24,7 +24,7 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo; import javax.ws.rs.core.UriInfo;
import java.util.function.Consumer; import java.util.function.Consumer;
import static sonia.scm.user.InvalidPasswordException.PASSWORD_NOT_MATCHED; import static sonia.scm.user.InvalidPasswordException.PWD_NOT_MATCHED;
/** /**
@@ -89,7 +89,7 @@ public class MeResource {
private Consumer<User> getOldOriginalPasswordChecker(String oldPassword) { private Consumer<User> getOldOriginalPasswordChecker(String oldPassword) {
return user -> { return user -> {
if (!user.getPassword().equals(passwordService.encryptPassword(oldPassword))) { if (!user.getPassword().equals(passwordService.encryptPassword(oldPassword))) {
throw new InvalidPasswordException(PASSWORD_NOT_MATCHED); throw new InvalidPasswordException(PWD_NOT_MATCHED);
} }
}; };
} }