Skip to content

Commit

Permalink
Migrate core.Logins and operations away from email address (#668)
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-adam authored Nov 7, 2024
1 parent 771bd5c commit 8a579b7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 41 deletions.
35 changes: 0 additions & 35 deletions src/org/labkey/cds/CDSController.java
Original file line number Diff line number Diff line change
Expand Up @@ -1070,41 +1070,6 @@ public void setAntigenQuery(String antigenQuery)
}
}

@RequiresSiteAdmin
public static class MailMergeAction extends SimpleViewAction<Object>
{
@Override
public ModelAndView getView(Object o, BindException errors) throws SQLException, IOException
{
if ("GET".equals(getViewContext().getRequest().getMethod()))
{
String csrf = new CsrfInput(getViewContext()).toString();
return new HtmlView("<form method=POST><input type=submit value=submit>" + csrf + "</form>");
}
else if ("POST".equals(getViewContext().getRequest().getMethod()))
{
String sql = "SELECT L.email, U.lastlogin, L.verification, U.displayname, U.firstname, U.lastname FROM core.logins L INNER JOIN core.principals P ON L.email = P.name INNER JOIN core.usersdata U ON P.userid = U.userid";
try (StashingResultsFactory factory = new StashingResultsFactory(()->new ResultsImpl(new SqlSelector(CoreSchema.getInstance().getScope(), sql).getResultSet())))
{
Results results = factory.get();
List<DisplayColumn> list = new ArrayList<>();
for (String s : Arrays.asList("email", "displayname", "firstname", "lastname", "lastlogin", "verification"))
list.add(new DataColumn(new BaseColumnInfo(s, JdbcType.valueOf(results.getMetaData().getColumnType(results.findColumn(s))))));
ExcelWriter xl = new ExcelWriter(factory, list);
xl.setFilenamePrefix("mailmerge");
xl.setAutoSize(true);
xl.renderWorkbook(getViewContext().getResponse());
}
}
return null;
}

@Override
public void addNavTrail(NavTree root)
{
}
}

@RequiresPermission(ReadPermission.class)
@MethodsAllowed({Method.POST, Method.DELETE})
public class UserPropertyAction extends MutatingApiAction<SimpleApiJsonForm>
Expand Down
4 changes: 2 additions & 2 deletions test/src/org/labkey/test/tests/cds/CDSLoginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public void testPasswordStrength()
DbLoginUtils.PasswordExpiration.Never);

log("Creating a user with password strength as Good");
_userHelper.createUser(CDS_LOGIN_TESTUSER);
SetPasswordForm.goToInitialPasswordForUser(this, CDS_LOGIN_TESTUSER)
int userId = _userHelper.createUser(CDS_LOGIN_TESTUSER).getUserId();
SetPasswordForm.goToInitialPasswordForUser(this, userId)
.setNewPassword(goodPwd)
.clickSubmit();
log("Make the user as folder admin for CDS");
Expand Down
2 changes: 1 addition & 1 deletion webapp/Connector/src/controller/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Ext.define('Connector.controller.Router', {
this.BAD_AUTH = false;
var me = this;

/* If the user recieves an unauthorized, return them to login screen */
/* If the user receives an unauthorized, return them to login screen */
this.application.on('httpunauthorized', function(status, text) {
me.BAD_AUTH = true;
Ext.Ajax.abortAll();
Expand Down
6 changes: 3 additions & 3 deletions webapp/frontPage/js/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ define(['jquery', 'magnific', 'util'], function($, magnific, util) {
var newLocation = LABKEY.ActionURL.buildURL('cds', 'app.view', null, {
'change_password': true,
'message': params.message,
'email': $sign_in_email.val()
'userId': params.userId
});
window.location = newLocation;
return;
Expand Down Expand Up @@ -429,7 +429,7 @@ define(['jquery', 'magnific', 'util'], function($, magnific, util) {
return false;
}

var emailVal = LABKEY.ActionURL.getParameter('email');
var userIdVal = LABKEY.ActionURL.getParameter('userId');
var prevPassword = document.getElementById('prevPassword');
$.ajax({
url: LABKEY.ActionURL.buildURL("login", "changePasswordAPI.api"),
Expand All @@ -438,7 +438,7 @@ define(['jquery', 'magnific', 'util'], function($, magnific, util) {
oldPassword: prevPassword.value,
password: pw1.value,
password2: pw2.value,
email: emailVal,
userId: userIdVal,
'X-LABKEY-CSRF': LABKEY.CSRF
},
success: function() {
Expand Down

0 comments on commit 8a579b7

Please sign in to comment.