Skip to content

Commit

Permalink
Migrate core.Logins and operations away from email address (#456)
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-adam authored Nov 7, 2024
1 parent 4a3e040 commit c8181f8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
import org.labkey.api.query.ValidationException;
import org.labkey.api.security.AdminConsoleAction;
import org.labkey.api.security.Group;
import org.labkey.api.security.LoginManager;
import org.labkey.api.security.MutableSecurityPolicy;
import org.labkey.api.security.PrincipalType;
import org.labkey.api.security.RequiresAnyOf;
Expand Down Expand Up @@ -889,7 +890,7 @@ public boolean handlePost(PublicDataUseForm form, BindException errors)
errors.reject(ERROR_MSG, "User with given email address does not exist");
return false;
}
if (!SecurityManager.matchPassword(form.getUserPassword(), SecurityManager.getPasswordHash(validEmail)))
if (!LoginManager.matchPassword(form.getUserPassword(), LoginManager.getPasswordHash(user)))
{
errors.reject(ERROR_MSG, "Incorrect password for " + user.getEmail());
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.labkey.api.query.ValidationException;
import org.labkey.api.security.Group;
import org.labkey.api.security.InvalidGroupMembershipException;
import org.labkey.api.security.LoginManager;
import org.labkey.api.security.MemberType;
import org.labkey.api.security.MutableSecurityPolicy;
import org.labkey.api.security.PasswordRule;
Expand Down Expand Up @@ -649,7 +650,7 @@ private ReviewerAndPassword createReviewerAccount(String reviewerEmailPrefix, Us

log.info("Generating password.");
String password = createPassword(newUser.getUser());
SecurityManager.setPassword(email, password);
LoginManager.setPassword(newUser.getUser(), password);
log.info("Set reviewer password successfully.");

return new ReviewerAndPassword(newUser.getUser(), password);
Expand Down
5 changes: 3 additions & 2 deletions signup/src/org/labkey/signup/SignUpController.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.labkey.api.security.AuthenticationManager.AuthenticationResult;
import org.labkey.api.security.DbLoginService;
import org.labkey.api.security.Group;
import org.labkey.api.security.LoginManager;
import org.labkey.api.security.RequiresLogin;
import org.labkey.api.security.RequiresNoPermission;
import org.labkey.api.security.RequiresPermission;
Expand Down Expand Up @@ -422,7 +423,7 @@ public boolean handlePost(SignupConfirmForm form, BindException errors) throws E
newUser.setDescription(StringUtils.isBlank(_tempUser.getOrganization()) ? "" : "Organization: " + _tempUser.getOrganization()); // don't add anything if organization is empty

// Attempt to set this new user's password and log them in
AuthenticationResult result = DbLoginService.get().attemptSetPassword(getContainer(), getUser(), form.getPassword(), form.getPassword2(), getViewContext().getRequest(), _email, PageFlowUtil.urlProvider(ProjectUrls.class).getHomeURL(), "Verified and chose a password.", true, errors);
AuthenticationResult result = DbLoginService.get().attemptSetPassword(getContainer(), getUser(), form.getPassword(), form.getPassword2(), getViewContext().getRequest(), newUser, PageFlowUtil.urlProvider(ProjectUrls.class).getHomeURL(), "Verified and chose a password.", true, false, errors);

if (errors.hasErrors())
return false;
Expand Down Expand Up @@ -839,7 +840,7 @@ private TempUser getTempUser(SignupForm signupForm, ValidEmail email) throws jav
tempUser.setFirstName(signupForm.getFirstName());
tempUser.setLastName(signupForm.getLastName());
tempUser.setOrganization(signupForm.getOrganization());
tempUser.setKey(SecurityManager.createTempPassword());
tempUser.setKey(LoginManager.createTempPassword());
tempUser.setContainer(getContainer());

Table.insert(null, SignUpManager.getTableInfoTempUsers(), tempUser);
Expand Down

0 comments on commit c8181f8

Please sign in to comment.