This commit is contained in:
Mohamed Karray
2018-09-20 11:51:10 +02:00
parent abe63140dd
commit b80e9666aa
13 changed files with 40 additions and 40 deletions

View File

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

View File

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

View File

@@ -41,6 +41,8 @@ import sonia.scm.search.Searchable;
import java.text.MessageFormat;
import java.util.function.Consumer;
import static sonia.scm.user.ChangePasswordNotAllowedException.WRON_USER_TYPE;
/**
* The central class for managing {@link User} objects.
* This class is a singleton and is available via injection.
@@ -79,7 +81,7 @@ public interface UserManager
default Consumer<User> getUserTypeChecker() {
return user -> {
if (!isTypeDefault(user)) {
throw new ChangePasswordNotAllowedException(MessageFormat.format("It is not possible to change password for User of type {0}", user.getType()));
throw new ChangePasswordNotAllowedException(MessageFormat.format(WRON_USER_TYPE, user.getType()));
}
};
}