Hello again, CUBA Team!
I’m attempting to finish up my User Registration project using the sample-user-registration project, but the “Restore Password” portion is not finding the user, and the code is unchanged from the sample project. The error message is triggered every time. The code is:
/**
* "Send new password" button click handler.
*/
@Subscribe("okBtn")
public void onOkBtnClick(Button.ClickEvent event) {
// validate required fields first
if (validateScreen()) {
LoadContext<User> lc = LoadContext.create(User.class);
lc.setView(View.MINIMAL);
lc.setQueryString("select u from sec$User u where u.loginLowerCase = :login and (u.active = true or u.active is null)")
.setParameter("login", loginField.getValue());
User targetUser = dataManager.load(lc);
if (targetUser == null) {
warningLabel.setVisible(true);
loginField.focus();
} else {
// generate new temporary password and send email
// user must have specified e-mail in the database
userManagementService.changePasswordsAtLogonAndSendEmails(Collections.singletonList(targetUser.getId()));
notifications.create(Notifications.NotificationType.TRAY)
.withCaption("Success")
.withDescription("E-mail with your new password has been sent")
.show();
close(WINDOW_COMMIT_AND_CLOSE_ACTION);
}
}
}
It always gets stuck in the targetUser == null block.
I’m curious if there is something not quite right in the sample code, or if I need to do something extra to get this to load the user properly. I’ve verified that the logins do exist and are active.
Thanks,
Adam