use of com.axelor.apps.base.service.user.UserService in project axelor-open-suite by axelor.
the class UserController method validatePassword.
public void validatePassword(ActionRequest request, ActionResponse response) {
try {
UserService userService = Beans.get(UserService.class);
String newPassword = MoreObjects.firstNonNull((String) request.getContext().get("newPassword"), "");
boolean valid = userService.matchPasswordPattern(newPassword);
response.setAttr("passwordPatternDescriptionLabel", "hidden", valid);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.base.service.user.UserService in project axelor-open-suite by axelor.
the class UserController method validate.
public void validate(ActionRequest request, ActionResponse response) {
try {
Context context = request.getContext();
User user = request.getContext().asType(User.class);
Map<String, String> errors = ModelTool.getUniqueErrors(user, UNIQUE_MESSAGES);
if (!errors.isEmpty()) {
response.setErrors(errors);
return;
}
UserService userService = Beans.get(UserService.class);
user = userService.changeUserPassword(user, context);
response.setValue("transientPassword", user.getTransientPassword());
} catch (ValidationException e) {
response.setError(e.getMessage());
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
use of com.axelor.apps.base.service.user.UserService in project axelor-open-suite by axelor.
the class UserController method generateRandomPassword.
public void generateRandomPassword(ActionRequest request, ActionResponse response) {
try {
UserService userService = Beans.get(UserService.class);
CharSequence password = userService.generateRandomPassword();
response.setValue("newPassword", password);
response.setValue("chkPassword", password);
} catch (Exception e) {
TraceBackService.trace(response, e);
}
}
Aggregations