diff --git a/Dnn.AdminExperience/ClientSide/Servers.Web/src/components/Tabs/SmtpServer.jsx b/Dnn.AdminExperience/ClientSide/Servers.Web/src/components/Tabs/SmtpServer.jsx
index 9068920e9e0..fdd4fac4d87 100644
--- a/Dnn.AdminExperience/ClientSide/Servers.Web/src/components/Tabs/SmtpServer.jsx
+++ b/Dnn.AdminExperience/ClientSide/Servers.Web/src/components/Tabs/SmtpServer.jsx
@@ -3,6 +3,7 @@ import PropTypes from "prop-types";
import { GridSystem, Button } from "@dnnsoftware/dnn-react-common";
import RadioButtonBlock from "../common/RadioButtonBlock";
import EditBlock from "../common/EditBlock";
+import EditPwdBlock from "../common/EditPwdBlock";
import SwitchBlock from "../common/SwitchBlock";
import localization from "../../localization";
import { connect } from "react-redux";
@@ -159,7 +160,9 @@ class SmtpServer extends Component {
return (
-
{localization.get("NonCoreMailProvider")}
+
+ {localization.get("NonCoreMailProvider")}
+
);
@@ -241,7 +244,7 @@ class SmtpServer extends Component {
)}
{smtpSettingsVisible && credentialVisible && (
-
+
-
+ props.onChangeSmtpConfigurationValue("smtpPassword", "")
+ }
error={props.errors["smtpPassword"]}
/>
)}
{smtpSettingsVisible && (
-
+
-
- {props.isGlobal && }
-
- ;
- }
+ return (
+
+
+ {props.isGlobal && }
+
+
+ );
+ }
}
EditBlock.propTypes = {
- label: PropTypes.string,
- tooltip: PropTypes.string,
- value: PropTypes.string,
- isGlobal: PropTypes.bool.isRequired,
- type: PropTypes.string,
- onChange: PropTypes.func,
- error: PropTypes.string
+ label: PropTypes.string,
+ tooltip: PropTypes.string,
+ value: PropTypes.string,
+ isGlobal: PropTypes.bool.isRequired,
+ type: PropTypes.string,
+ onChange: PropTypes.func,
+ error: PropTypes.string,
};
EditBlock.defaultProps = {
- isGlobal: false
-};
\ No newline at end of file
+ isGlobal: false,
+};
diff --git a/Dnn.AdminExperience/ClientSide/Servers.Web/src/components/common/EditPwdBlock.jsx b/Dnn.AdminExperience/ClientSide/Servers.Web/src/components/common/EditPwdBlock.jsx
new file mode 100644
index 00000000000..18bde599d48
--- /dev/null
+++ b/Dnn.AdminExperience/ClientSide/Servers.Web/src/components/common/EditPwdBlock.jsx
@@ -0,0 +1,72 @@
+import React, { Component } from "react";
+import PropTypes from "prop-types";
+import {
+ Label,
+ InputGroup,
+ SingleLineInputWithError,
+} from "@dnnsoftware/dnn-react-common";
+import GlobalIcon from "./GlobalIcon";
+
+export default class EditPwdBlock extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ canChange: props.value === "",
+ };
+ }
+ render() {
+ const { props, state } = this;
+ console.log(state);
+
+ return (
+
+
+ {props.isGlobal && }
+ {state.canChange ? (
+
+ ) : (
+
+ )}
+
+ );
+ }
+}
+
+EditPwdBlock.propTypes = {
+ label: PropTypes.string,
+ changeButtonText: PropTypes.string,
+ tooltip: PropTypes.string,
+ value: PropTypes.string,
+ isGlobal: PropTypes.bool.isRequired,
+ onChange: PropTypes.func,
+ onClear: PropTypes.func,
+ error: PropTypes.string,
+};
+
+EditPwdBlock.defaultProps = {
+ isGlobal: false,
+};
diff --git a/Dnn.AdminExperience/ClientSide/Servers.Web/src/components/common/style.less b/Dnn.AdminExperience/ClientSide/Servers.Web/src/components/common/style.less
index dff6e04cc47..af0fdcee4a5 100644
--- a/Dnn.AdminExperience/ClientSide/Servers.Web/src/components/common/style.less
+++ b/Dnn.AdminExperience/ClientSide/Servers.Web/src/components/common/style.less
@@ -1,29 +1,43 @@
.dnn-servers-info-panel-big .serversTabWarningInfo {
+ color: red;
+ margin-bottom: 32px;
+
+ .title label {
+ text-transform: none;
+ }
+
+ .dnn-label {
+ width: 95%;
+ padding: 5px;
+ padding-bottom: 20px;
color: red;
- margin-bottom: 32px;
-
- .title label {
- text-transform: none;
+ font-weight: bold;
+ }
+
+ div {
+ float: left;
+ svg {
+ width: 20px;
+ height: 20px;
+ fill: red;
+ margin-top: 4px;
+ :hover {
+ fill: red;
+ }
}
-
- .dnn-label {
- width: 95%;
- padding: 5px;
- padding-bottom: 20px;
- color: red;
- font-weight: bold;
- }
-
- div {
- float: left;
- svg {
- width: 20px;
- height: 20px;
- fill: red;
- margin-top:4px;
- :hover {
- fill: red;
- }
- }
- }
-}
\ No newline at end of file
+ }
+}
+
+.dnn-ui-common-input-group div a {
+ color: #00a0e9;
+ font-weight: bold;
+ text-decoration: underline;
+}
+
+.dnn-ui-common-input-group .edit-pwd-button {
+ display: block;
+ width: 100%;
+ float: left;
+ height: 62px;
+ padding-top: 4px;
+}
diff --git a/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/ServerSettingsSmtpAdminController.cs b/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/ServerSettingsSmtpAdminController.cs
index 2c9c7c9b296..d127ffd1b49 100644
--- a/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/ServerSettingsSmtpAdminController.cs
+++ b/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/ServerSettingsSmtpAdminController.cs
@@ -28,6 +28,7 @@ namespace Dnn.PersonaBar.Servers.Services
[MenuPermission(Scope = ServiceScope.Admin)]
public class ServerSettingsSmtpAdminController : PersonaBarApiController
{
+ private const string ObfuscateString = "*****";
private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(ServerSettingsSmtpHostController));
[HttpGet]
@@ -49,7 +50,7 @@ public HttpResponseMessage GetSmtpSettings()
smtpAuthentication = PortalController.GetPortalSetting("SMTPAuthentication", portalId, "0"),
enableSmtpSsl = PortalController.GetPortalSetting("SMTPEnableSSL", portalId, string.Empty) == "Y",
smtpUserName = PortalController.GetPortalSetting("SMTPUsername", portalId, string.Empty),
- smtpPassword = PortalController.GetEncryptedString("SMTPPassword", portalId, Config.GetDecryptionkey()),
+ smtpPassword = GetSmtpPassword(portalId, true),
},
portalName = PortalSettings.Current.PortalName,
hideCoreSettings = ProviderConfiguration.GetProviderConfiguration("mail").GetDefaultProvider().Attributes.GetValueOrDefault("hideCoreSettings", false),
@@ -72,6 +73,11 @@ public HttpResponseMessage UpdateSmtpSettings(UpdateSmtpSettingsRequest request)
var portalId = PortalSettings.Current.PortalId;
PortalController.UpdatePortalSetting(portalId, "SMTPmode", request.SmtpServerMode, false);
+ if (request.SmtpPassword == ObfuscateString)
+ {
+ request.SmtpPassword = GetSmtpPassword(portalId, false);
+ }
+
// admins can only change site settings
PortalController.UpdatePortalSetting(portalId, "SMTPServer", request.SmtpServer, false);
PortalController.UpdatePortalSetting(portalId, "SMTPConnectionLimit", request.SmtpConnectionLimit, false);
@@ -111,14 +117,14 @@ public HttpResponseMessage SendTestEmail(SendTestEmailRequest request)
var errMessage = Mail.SendMail(mailFrom,
mailTo,
- "",
- "",
+ string.Empty,
+ string.Empty,
MailPriority.Normal,
Localization.GetSystemMessage(this.PortalSettings, "EMAIL_SMTP_TEST_SUBJECT"),
MailFormat.Text,
Encoding.UTF8,
- "",
- "",
+ string.Empty,
+ string.Empty,
smtpHostMode ? HostController.Instance.GetString("SMTPServer") : request.SmtpServer,
smtpHostMode ? HostController.Instance.GetString("SMTPAuthentication") : request.SmtpAuthentication.ToString(),
smtpHostMode ? HostController.Instance.GetString("SMTPUsername") : request.SmtpUsername,
@@ -145,5 +151,17 @@ public HttpResponseMessage SendTestEmail(SendTestEmailRequest request)
return this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc);
}
}
+
+ private static string GetSmtpPassword(int portalId, bool obfuscate)
+ {
+ var pwd = PortalController.GetEncryptedString("SMTPPassword", portalId, Config.GetDecryptionkey());
+
+ if (obfuscate && !string.IsNullOrEmpty(pwd))
+ {
+ return ObfuscateString;
+ }
+
+ return pwd;
+ }
}
}
diff --git a/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/ServerSettingsSmtpHostController.cs b/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/ServerSettingsSmtpHostController.cs
index c8b1e39e7ad..6009987cba8 100644
--- a/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/ServerSettingsSmtpHostController.cs
+++ b/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/ServerSettingsSmtpHostController.cs
@@ -27,7 +27,8 @@ namespace Dnn.PersonaBar.Servers.Services
[MenuPermission(Scope = ServiceScope.Host)]
public class ServerSettingsSmtpHostController : PersonaBarApiController
{
- private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(ServerSettingsSmtpHostController));
+ private const string ObfuscateString = "*****";
+ private static readonly ILog Logger = LoggerSource.Instance.GetLogger(typeof(ServerSettingsSmtpHostController));
[HttpGet]
public HttpResponseMessage GetSmtpSettings()
@@ -47,7 +48,7 @@ public HttpResponseMessage GetSmtpSettings()
smtpAuthentication = HostController.Instance.GetString("SMTPAuthentication"),
enableSmtpSsl = HostController.Instance.GetBoolean("SMTPEnableSSL", false),
smtpUserName = HostController.Instance.GetString("SMTPUsername"),
- smtpPassword = string.Empty,
+ smtpPassword = GetSmtpPassword(-1, true),
smtpHostEmail = HostController.Instance.GetString("HostEmail"),
messageSchedulerBatchSize = Host.MessageSchedulerBatchSize,
},
@@ -59,7 +60,7 @@ public HttpResponseMessage GetSmtpSettings()
smtpAuthentication = PortalController.GetPortalSetting("SMTPAuthentication", portalId, "0"),
enableSmtpSsl = PortalController.GetPortalSetting("SMTPEnableSSL", portalId, string.Empty) == "Y",
smtpUserName = PortalController.GetPortalSetting("SMTPUsername", portalId, string.Empty),
- smtpPassword = PortalController.GetEncryptedString("SMTPPassword", portalId, Config.GetDecryptionkey()),
+ smtpPassword = GetSmtpPassword(portalId, true),
},
portalName = PortalSettings.Current.PortalName,
hideCoreSettings = ProviderConfiguration.GetProviderConfiguration("mail").GetDefaultProvider().Attributes.GetValueOrDefault("hideCoreSettings", false),
@@ -82,13 +83,13 @@ public HttpResponseMessage UpdateSmtpSettings(UpdateSmtpSettingsRequest request)
var portalId = PortalSettings.Current.PortalId;
PortalController.UpdatePortalSetting(portalId, "SMTPmode", request.SmtpServerMode, false);
- if (string.IsNullOrWhiteSpace(request.SmtpPassword))
- {
- request.SmtpPassword = GetSmtpPassword();
- }
-
if (request.SmtpServerMode == "h")
- {
+ {
+ if (request.SmtpPassword == ObfuscateString)
+ {
+ request.SmtpPassword = GetHostSmtpPassword();
+ }
+
HostController.Instance.Update("SMTPServer", request.SmtpServer, false);
HostController.Instance.Update("SMTPConnectionLimit", request.SmtpConnectionLimit, false);
HostController.Instance.Update("SMTPMaxIdleTime", request.SmtpMaxIdleTime, false);
@@ -103,6 +104,11 @@ public HttpResponseMessage UpdateSmtpSettings(UpdateSmtpSettingsRequest request)
}
else
{
+ if (request.SmtpPassword == ObfuscateString)
+ {
+ request.SmtpPassword = GetSmtpPassword(portalId, false);
+ }
+
PortalController.UpdatePortalSetting(portalId, "SMTPServer", request.SmtpServer, false);
PortalController.UpdatePortalSetting(portalId, "SMTPConnectionLimit", request.SmtpConnectionLimit, false);
PortalController.UpdatePortalSetting(portalId, "SMTPMaxIdleTime", request.SmtpMaxIdleTime, false);
@@ -140,14 +146,14 @@ public HttpResponseMessage SendTestEmail(SendTestEmailRequest request)
var errMessage = Mail.SendMail(mailFrom,
mailTo,
- "",
- "",
+ string.Empty,
+ string.Empty,
MailPriority.Normal,
Localization.GetSystemMessage(this.PortalSettings, "EMAIL_SMTP_TEST_SUBJECT"),
MailFormat.Text,
Encoding.UTF8,
- "",
- "",
+ string.Empty,
+ string.Empty,
request.SmtpServer,
request.SmtpAuthentication.ToString(),
request.SmtpUsername,
@@ -177,7 +183,27 @@ public HttpResponseMessage SendTestEmail(SendTestEmailRequest request)
}
}
- private static string GetSmtpPassword()
+ private static string GetSmtpPassword(int portalId, bool obfuscate)
+ {
+ var pwd = string.Empty;
+ if (portalId == -1)
+ {
+ pwd = GetHostSmtpPassword();
+ }
+ else
+ {
+ pwd = PortalController.GetEncryptedString("SMTPPassword", portalId, Config.GetDecryptionkey());
+ }
+
+ if (obfuscate && !string.IsNullOrEmpty(pwd))
+ {
+ return ObfuscateString;
+ }
+
+ return pwd;
+ }
+
+ private static string GetHostSmtpPassword()
{
string decryptedText;
try
diff --git a/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/admin/personaBar/Dnn.Servers/App_LocalResources/Servers.resx b/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/admin/personaBar/Dnn.Servers/App_LocalResources/Servers.resx
index 1199957818a..9f6c6d73a97 100644
--- a/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/admin/personaBar/Dnn.Servers/App_LocalResources/Servers.resx
+++ b/Dnn.AdminExperience/Dnn.PersonaBar.Extensions/admin/personaBar/Dnn.Servers/App_LocalResources/Servers.resx
@@ -717,4 +717,7 @@ Are you sure you want to increment the version number for your site?
You can delete all servers that have not been active for 24 hours below
-
+
+ Change
+
+
\ No newline at end of file