Skip to content

Commit

Permalink
Merge 22.11 to develop
Browse files Browse the repository at this point in the history
  • Loading branch information
labkey-teamcity committed Nov 29, 2022
2 parents c88fd9d + 9b019b0 commit 1ad8e07
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 42 deletions.
18 changes: 6 additions & 12 deletions api/src/org/labkey/api/security/SecurityManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.junit.Before;
import org.junit.Test;
import org.labkey.api.action.LabKeyError;
import org.labkey.api.action.LabKeyErrorWithHtml;
import org.labkey.api.action.MutatingApiAction;
import org.labkey.api.action.SpringActionController;
import org.labkey.api.audit.AuditLogService;
Expand Down Expand Up @@ -2489,11 +2490,6 @@ public static void sendRegistrationEmail(ViewContext context, ValidEmail email,
}
}

public static void addSelfRegisteredUser(ViewContext context, ValidEmail email, @Nullable List<Pair<String, String>> extraParameters) throws Exception
{
addSelfRegisteredUser(context, email, extraParameters, null);
}

public static void addSelfRegisteredUser(ViewContext context, ValidEmail email, @Nullable List<Pair<String, String>> extraParameters, @Nullable String registrationProviderName) throws Exception
{
User currentUser = context.getUser();
Expand Down Expand Up @@ -2527,13 +2523,13 @@ private static void appendMailHelpText(HtmlStringBuilder builder, ActionURL mess
if (messageContentsURL != null)
{
builder.append(" Alternatively, you can copy the ");
builder.append(new LinkBuilder("contents of the message").href(messageContentsURL).target("_blank"));
builder.append(new LinkBuilder("contents of the message").href(messageContentsURL).target("_blank").clearClasses());
builder.append(" into an email client and send it to the user manually.");
}

builder.append(HtmlString.unsafe("</p>"));
builder.append(HtmlString.unsafe("<p>For help on fixing your mail server settings, please consult the SMTP section of the "));
builder.append(new HelpTopic("cpasxml").getSimpleLinkHtml("LabKey documentation on modifying your configuration file"));
builder.append(new HelpTopic("labkeyxml").getSimpleLinkHtml("LabKey documentation on modifying your configuration file"));
builder.append(".").append(HtmlString.BR);
}
else
Expand Down Expand Up @@ -2807,10 +2803,10 @@ public static boolean canSeeFilePaths(Container c, User user)

public static void adminRotatePassword(ValidEmail email, BindException errors, Container c, User user)
{
adminRotatePassword(email, errors, c, user, "");
adminRotatePassword(email, errors, c, user, HtmlString.EMPTY_STRING);
}

public static void adminRotatePassword(ValidEmail email, BindException errors, Container c, User user, String mailErrorText)
public static void adminRotatePassword(ValidEmail email, BindException errors, Container c, User user, HtmlString mailErrorHtml)
{
// We let admins create passwords (i.e., entries in the logins table) if they don't already exist.
// This addresses SSO and LDAP scenarios, see #10374.
Expand Down Expand Up @@ -2851,9 +2847,7 @@ public static void adminRotatePassword(ValidEmail email, BindException errors, C
catch (ConfigurationException | MessagingException e)
{
String message = "Failed to send email due to: " + e.getMessage();
if (StringUtils.isNotBlank(mailErrorText))
message += '\n' + mailErrorText;
errors.addError(new LabKeyError(new Exception(message, e)));
errors.addError(mailErrorHtml.length() != 0 ? new LabKeyErrorWithHtml(message, mailErrorHtml) : new LabKeyError(message));
UserManager.addToUserHistory(UserManager.getUser(email), user.getEmail() + " " + pastVerb + " the password, but sending the email failed.");
}
}
Expand Down
2 changes: 1 addition & 1 deletion api/src/org/labkey/api/view/HtmlView.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public HtmlView(String html)
this(HtmlString.unsafe(html));
}

/** Use the HtmlString or or Renderable constructor instead */
/** Use the HtmlString or Renderable constructor instead */
@Deprecated
public HtmlView(String title, String html)
{
Expand Down
2 changes: 1 addition & 1 deletion core/resources/scripts/labkey/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ LABKEY.Utils = require("./Utils").Utils;/**
* <p>Additional documentation on SMTP setup for LabKey Server:
* <ul>
* <li><a href="https://www.labkey.org/Documentation/wiki-page.view?name=configWindows">Install LabKey via the Installer</a></li>
* <li><a href="https://www.labkey.org/Documentation/wiki-page.view?name=cpasxml">Modify the Configuration File -- Includes SMTP Settings</a></li>
* <li><a href="https://www.labkey.org/Documentation/wiki-page.view?name=labkeyxml">Modify the Configuration File -- Includes SMTP Settings</a></li>
* </ul>
* </p>
*/
Expand Down
54 changes: 29 additions & 25 deletions core/src/org/labkey/core/security/SecurityController.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
import org.labkey.api.util.HelpTopic;
import org.labkey.api.util.HtmlString;
import org.labkey.api.util.HtmlStringBuilder;
import org.labkey.api.util.Link;
import org.labkey.api.util.PageFlowUtil;
import org.labkey.api.util.Pair;
import org.labkey.api.util.TestContext;
Expand Down Expand Up @@ -1734,50 +1735,53 @@ public ModelAndView getSuccessView(EmailForm form)
@Override
public ModelAndView getFailView(EmailForm form, BindException errors)
{
String errorMessage = PageFlowUtil.filter(getErrorMessage(errors));

String page = String.format(
"<p>%1$s: Password %2$s.</p><p>%3$s</p>%4$s",
PageFlowUtil.filter(form.getEmail()),
_loginExists ? "reset" : "created",
errorMessage,
PageFlowUtil.button("Done").href(form.getReturnURLHelper(AppProps.getInstance().getHomePageActionURL()))
);
HtmlStringBuilder builder = HtmlStringBuilder.of()
.append(HtmlString.unsafe("<p>"))
.append(form.getEmail() + ": Password " + (_loginExists ? "reset" : "created") + ".")
.append(HtmlString.unsafe("</p><p>"))
.append(getErrorMessage(errors))
.append(HtmlString.unsafe("</p>"))
.append(PageFlowUtil.button("Done").href(form.getReturnURLHelper(AppProps.getInstance().getHomePageActionURL())));

getPageConfig().setTemplate(PageConfig.Template.Dialog);
setTitle("Password Reset Failed");
return new HtmlView(page);
return new HtmlView(builder);
}

private String getErrorMessage(BindException errors)
private HtmlString getErrorMessage(BindException errors)
{
StringBuilder sb = new StringBuilder();
HtmlStringBuilder builder = HtmlStringBuilder.of();

for(ObjectError e : errors.getAllErrors())
{
sb.append(e.getDefaultMessage()).append('\n');
if (e instanceof LabKeyError le)
builder.append(le.renderToHTML(getViewContext()));
else
builder.append(e.getDefaultMessage()).append('\n');
}

return sb.toString();
return builder.getHtmlString();
}

private String getMailHelpText(String emailAddress)
private HtmlString getMailHelpText(String emailAddress)
{
ActionURL mailHref = new ActionURL(ShowResetEmailAction.class, getContainer()).addParameter("email", emailAddress);

StringBuilder sb = new StringBuilder();
sb.append("<p>You can attempt to resend this mail later by going to the Site Users link, clicking on the appropriate user from the list, and resetting their password.");
HtmlStringBuilder builder = HtmlStringBuilder.of()
.append(HtmlString.unsafe("<p>"))
.append("You can attempt to resend this mail later by going to the Site Users link, clicking on the appropriate user from the list, and resetting their password.");
if (mailHref != null)
{
sb.append(" Alternatively, you can copy the <a href=\"");
sb.append(mailHref);
sb.append("\" target=\"_blank\">contents of the message</a> into an email client and send it to the user manually.");
builder.append(" Alternatively, you can copy the ")
.append(new Link.LinkBuilder("contents of the message").href(mailHref).target("_blank").clearClasses())
.append(" into an email client and send it to the user manually.");
}
sb.append("</p>");
sb.append("<p>For help on fixing your mail server settings, please consult the SMTP section of the ");
sb.append(new HelpTopic("cpasxml").getSimpleLinkHtml("LabKey Server documentation on modifying your configuration file"));
sb.append(".</p>");
builder.append(HtmlString.unsafe("</p>\n<p>"))
.append("For help on fixing your mail server settings, please consult the SMTP section of the ")
.append(new HelpTopic("labkeyxml").getSimpleLinkHtml("LabKey Server documentation on modifying your configuration file"))
.append(HtmlString.unsafe(".</p>"));

return sb.toString();
return builder.getHtmlString();
}
}

Expand Down
10 changes: 7 additions & 3 deletions internal/webapp/extWidgets/Ext4FormPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,11 +532,15 @@ Ext4.define('LABKEY.ext4.DatabindPlugin', {
var findMatchingField = function(f) {
if (f.isFormField) {
if (f.dataIndex) {
this.addFieldListener(c);
this.addFieldListener(f);
} else if (f.isComposite) {
f.items.each(findMatchingField, this);
}
}
// NOTE: this allows more complex nested containers
else if (f.isQueryable) {
f.items.each(findMatchingField, this);
}
};
findMatchingField.call(this, c);
}, this);
Expand All @@ -557,11 +561,11 @@ Ext4.define('LABKEY.ext4.DatabindPlugin', {
// Can only contain one row of data.
if (records.length == 0){
if(this.panel.bindConfig.createRecordOnLoad){
var values = this.getForm.getFieldValues();
var values = this.panel.getForm().getFieldValues();
var record = this.panel.store.model.create();
record.set(values); //otherwise record will not be dirty
record.phantom = true;
this.store.add(record);
this.panel.store.add(record);
this.bindRecord(record, true);
}
}
Expand Down

0 comments on commit 1ad8e07

Please sign in to comment.