mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-05-07 06:16:03 +02:00
review
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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()));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user