Add type back to exception message

This commit is contained in:
René Pfeuffer
2018-10-29 09:41:10 +01:00
parent 4425243f03
commit 224b8e6af4
2 changed files with 4 additions and 4 deletions

View File

@@ -6,10 +6,10 @@ import sonia.scm.ExceptionWithContext;
public class ChangePasswordNotAllowedException extends ExceptionWithContext { public class ChangePasswordNotAllowedException extends ExceptionWithContext {
private static final String CODE = "9BR7qpDAe1"; private static final String CODE = "9BR7qpDAe1";
public static final String WRONG_USER_TYPE = "User of given type are not allowed to change password"; public static final String WRONG_USER_TYPE = "User of type %s are not allowed to change password";
public ChangePasswordNotAllowedException(ContextEntry.ContextBuilder context) { public ChangePasswordNotAllowedException(ContextEntry.ContextBuilder context, String type) {
super(context.build(), WRONG_USER_TYPE); super(context.build(), String.format(WRONG_USER_TYPE, type));
} }
@Override @Override

View File

@@ -422,7 +422,7 @@ public class DefaultUserManager extends AbstractUserManager
throw new NotFoundException(User.class, userId); throw new NotFoundException(User.class, userId);
} }
if (!isTypeDefault(user)) { if (!isTypeDefault(user)) {
throw new ChangePasswordNotAllowedException(ContextEntry.ContextBuilder.entity("passwordChange", "-").in(User.class, user.getName())); throw new ChangePasswordNotAllowedException(ContextEntry.ContextBuilder.entity("passwordChange", "-").in(User.class, user.getName()), user.getType());
} }
user.setPassword(newPassword); user.setPassword(newPassword);
this.modify(user); this.modify(user);