use of com.infiniteautomation.mango.util.exception.TranslatableExceptionI in project ma-modules-public by infiniteautomation.
the class UserRestController method approveUsers.
@ApiOperation(value = "Approve publicly registered User(s)", notes = "Superadmin permission required", response = UserModel.class)
@RequestMapping(method = RequestMethod.POST, value = "/approve-users")
@PreAuthorize("isAdmin()")
public ApprovedUsersModel approveUsers(@RequestBody() ApproveUsersModel model) {
ApprovedUsersModel result = new ApprovedUsersModel();
for (String username : model.getUsernames()) {
try {
User approved = service.approveUser(username, model.isSendEmail());
result.addApproved(approved.getUsername());
} catch (Exception e) {
if (e instanceof TranslatableExceptionI) {
result.addFailedApproval(username, ((TranslatableExceptionI) e).getTranslatableMessage());
} else {
result.addFailedApproval(username, new TranslatableMessage("common.default", e.getMessage()));
}
}
}
return result;
}
Aggregations