|
|
@ -29,6 +29,8 @@ import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.validation.Errors; |
|
|
|
import org.springframework.validation.Errors; |
|
|
|
import org.springframework.validation.Validator; |
|
|
|
import org.springframework.validation.Validator; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Validator for {@link UserSettingsController}. |
|
|
|
* Validator for {@link UserSettingsController}. |
|
|
|
* |
|
|
|
* |
|
|
@ -41,6 +43,8 @@ public class UserSettingsValidator implements Validator { |
|
|
|
private SecurityService securityService; |
|
|
|
private SecurityService securityService; |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private SettingsService settingsService; |
|
|
|
private SettingsService settingsService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private HttpServletRequest request; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* {@inheritDoc} |
|
|
|
* {@inheritDoc} |
|
|
@ -85,6 +89,16 @@ public class UserSettingsValidator implements Validator { |
|
|
|
errors.rejectValue("password", "usersettings.passwordnotsupportedforldap"); |
|
|
|
errors.rejectValue("password", "usersettings.passwordnotsupportedforldap"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (securityService.getCurrentUser(request).getUsername().equals(username)) { |
|
|
|
|
|
|
|
// These errors don't need translation since the option isn't exposed to the user
|
|
|
|
|
|
|
|
if (command.isDeleteUser()) { |
|
|
|
|
|
|
|
errors.rejectValue("deleteUser", null, "Cannot delete the current user"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (! command.isAdminRole()) { |
|
|
|
|
|
|
|
errors.rejectValue("adminRole", null, "Cannot remove admin from the current user"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |