diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/SystemProxy.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/SystemProxy.cs index 9defc57d..d96d0a27 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/SystemProxy.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Client/SystemProxy.cs @@ -1,35 +1,7 @@ -// Copyright (c) 2015, Outercurve Foundation. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without modification, -// are permitted provided that the following conditions are met: -// -// - Redistributions of source code must retain the above copyright notice, this -// list of conditions and the following disclaimer. -// -// - Redistributions in binary form must reproduce the above copyright notice, -// this list of conditions and the following disclaimer in the documentation -// and/or other materials provided with the distribution. -// -// - Neither the name of the Outercurve Foundation nor the names of its -// contributors may be used to endorse or promote products derived from this -// software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:2.0.50727.42 +// Runtime Version:2.0.50727.7905 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -37,19 +9,19 @@ //------------------------------------------------------------------------------ // -// This source code was auto-generated by wsdl, Version=2.0.50727.42. +// This source code was auto-generated by wsdl, Version=2.0.50727.3038. // namespace WebsitePanel.EnterpriseServer { - using System.Diagnostics; + using System.Xml.Serialization; using System.Web.Services; using System.ComponentModel; using System.Web.Services.Protocols; using System; - using System.Xml.Serialization; + using System.Diagnostics; /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Web.Services.WebServiceBindingAttribute(Name="esSystemSoap", Namespace="http://tempuri.org/")] @@ -57,16 +29,21 @@ namespace WebsitePanel.EnterpriseServer { private System.Threading.SendOrPostCallback GetSystemSettingsOperationCompleted; + private System.Threading.SendOrPostCallback GetSystemSettingsActiveOperationCompleted; + private System.Threading.SendOrPostCallback SetSystemSettingsOperationCompleted; /// public esSystem() { - this.Url = "http://localhost/EnterpriseServer/esSystem.asmx"; + this.Url = "http://localhost:9002/esSystem.asmx"; } /// public event GetSystemSettingsCompletedEventHandler GetSystemSettingsCompleted; + /// + public event GetSystemSettingsActiveCompletedEventHandler GetSystemSettingsActiveCompleted; + /// public event SetSystemSettingsCompletedEventHandler SetSystemSettingsCompleted; @@ -111,6 +88,50 @@ namespace WebsitePanel.EnterpriseServer { } } + /// + [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetSystemSettingsActive", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] + public SystemSettings GetSystemSettingsActive(string settingsName, bool decrypt) { + object[] results = this.Invoke("GetSystemSettingsActive", new object[] { + settingsName, + decrypt}); + return ((SystemSettings)(results[0])); + } + + /// + public System.IAsyncResult BeginGetSystemSettingsActive(string settingsName, bool decrypt, System.AsyncCallback callback, object asyncState) { + return this.BeginInvoke("GetSystemSettingsActive", new object[] { + settingsName, + decrypt}, callback, asyncState); + } + + /// + public SystemSettings EndGetSystemSettingsActive(System.IAsyncResult asyncResult) { + object[] results = this.EndInvoke(asyncResult); + return ((SystemSettings)(results[0])); + } + + /// + public void GetSystemSettingsActiveAsync(string settingsName, bool decrypt) { + this.GetSystemSettingsActiveAsync(settingsName, decrypt, null); + } + + /// + public void GetSystemSettingsActiveAsync(string settingsName, bool decrypt, object userState) { + if ((this.GetSystemSettingsActiveOperationCompleted == null)) { + this.GetSystemSettingsActiveOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetSystemSettingsActiveOperationCompleted); + } + this.InvokeAsync("GetSystemSettingsActive", new object[] { + settingsName, + decrypt}, this.GetSystemSettingsActiveOperationCompleted, userState); + } + + private void OnGetSystemSettingsActiveOperationCompleted(object arg) { + if ((this.GetSystemSettingsActiveCompleted != null)) { + System.Web.Services.Protocols.InvokeCompletedEventArgs invokeArgs = ((System.Web.Services.Protocols.InvokeCompletedEventArgs)(arg)); + this.GetSystemSettingsActiveCompleted(this, new GetSystemSettingsActiveCompletedEventArgs(invokeArgs.Results, invokeArgs.Error, invokeArgs.Cancelled, invokeArgs.UserState)); + } + } + /// [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/SetSystemSettings", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)] public int SetSystemSettings(string settingsName, SystemSettings settings) { @@ -162,11 +183,11 @@ namespace WebsitePanel.EnterpriseServer { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] public delegate void GetSystemSettingsCompletedEventHandler(object sender, GetSystemSettingsCompletedEventArgs e); /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] public partial class GetSystemSettingsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { @@ -188,11 +209,37 @@ namespace WebsitePanel.EnterpriseServer { } /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + public delegate void GetSystemSettingsActiveCompletedEventHandler(object sender, GetSystemSettingsActiveCompletedEventArgs e); + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + public partial class GetSystemSettingsActiveCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { + + private object[] results; + + internal GetSystemSettingsActiveCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) : + base(exception, cancelled, userState) { + this.results = results; + } + + /// + public SystemSettings Result { + get { + this.RaiseExceptionIfNecessary(); + return ((SystemSettings)(this.results[0])); + } + } + } + + /// + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] public delegate void SetSystemSettingsCompletedEventHandler(object sender, SetSystemSettingsCompletedEventArgs e); /// - [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] public partial class SetSystemSettingsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/System/SystemController.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/System/SystemController.cs index 5b7d2832..1da3365d 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/System/SystemController.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer.Code/System/SystemController.cs @@ -53,6 +53,18 @@ namespace WebsitePanel.EnterpriseServer return GetSystemSettingsInternal(settingsName, !isDemoAccount); } + public static SystemSettings GetSystemSettingsActive(string settingsName, bool decrypt) + { + // check account + int accountCheck = SecurityContext.CheckAccount(DemandAccount.IsActive); + if (accountCheck < 0) + return null; + + bool isDemoAccount = (SecurityContext.CheckAccount(DemandAccount.NotDemo) < 0); + + return GetSystemSettingsInternal(settingsName, decrypt && isDemoAccount); + } + internal static SystemSettings GetSystemSettingsInternal(string settingsName, bool decryptPassword) { // create settings object diff --git a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esSystem.asmx.cs b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esSystem.asmx.cs index 71ad130e..26c44aee 100644 --- a/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esSystem.asmx.cs +++ b/WebsitePanel/Sources/WebsitePanel.EnterpriseServer/esSystem.asmx.cs @@ -53,6 +53,12 @@ namespace WebsitePanel.EnterpriseServer return SystemController.GetSystemSettings(settingsName); } + [WebMethod] + public SystemSettings GetSystemSettingsActive(string settingsName, bool decrypt) + { + return SystemController.GetSystemSettingsActive(settingsName, decrypt); + } + [WebMethod] public int SetSystemSettings(string settingsName, SystemSettings settings) { diff --git a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/AccountController.cs b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/AccountController.cs index b2c0bec9..8eee631a 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/AccountController.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebDavPortal/Controllers/AccountController.cs @@ -208,7 +208,14 @@ namespace WebsitePanel.WebDavPortal.Controllers var user = WspContext.Services.Organizations.GetUserGeneralSettings(accessToken.ItemId, accessToken.AccountId); - if (string.IsNullOrEmpty(user.MobilePhone)) + var settings = WspContext.Services.System.GetSystemSettingsActive(EnterpriseServer.SystemSettings.TWILIO_SETTINGS, false); + + bool twilioEnabled = settings != null + && !string.IsNullOrEmpty(settings.GetValueOrDefault(EnterpriseServer.SystemSettings.TWILIO_ACCOUNTSID_KEY, string.Empty)) + && !string.IsNullOrEmpty(settings.GetValueOrDefault(EnterpriseServer.SystemSettings.TWILIO_AUTHTOKEN_KEY, string.Empty)) + && !string.IsNullOrEmpty(settings.GetValueOrDefault(EnterpriseServer.SystemSettings.TWILIO_PHONEFROM_KEY, string.Empty)); + + if (string.IsNullOrEmpty(user.MobilePhone) || twilioEnabled == false) { var result = WspContext.Services.Organizations.SendResetUserPasswordPincodeEmail(accessToken.AccessTokenGuid, user.PrimaryEmailAddress); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/OrganizationUserResetPassword.ascx.resx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/OrganizationUserResetPassword.ascx.resx index a21310ff..1d2b9682 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/OrganizationUserResetPassword.ascx.resx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/App_LocalResources/OrganizationUserResetPassword.ascx.resx @@ -120,8 +120,8 @@ Send Password Reset Email - - Don't save as user mobile + + Save as user mobile Email: diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserResetPassword.ascx b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserResetPassword.ascx index f1e7870a..38d50539 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserResetPassword.ascx +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserResetPassword.ascx @@ -45,7 +45,7 @@ - + diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserResetPassword.ascx.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserResetPassword.ascx.cs index 7fea70e6..eeebc856 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserResetPassword.ascx.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserResetPassword.ascx.cs @@ -5,6 +5,7 @@ using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using WebsitePanel.Providers.HostedSolution; +using WSP = WebsitePanel.EnterpriseServer; namespace WebsitePanel.Portal.ExchangeServer { @@ -28,6 +29,15 @@ namespace WebsitePanel.Portal.ExchangeServer txtEmailAddress.Text = user.PrimaryEmailAddress; txtMobile.Text = user.MobilePhone; + + var settings = ES.Services.System.GetSystemSettingsActive(WSP.SystemSettings.TWILIO_SETTINGS, false); + + bool twilioEnabled = settings != null + && !string.IsNullOrEmpty(settings.GetValueOrDefault(WSP.SystemSettings.TWILIO_ACCOUNTSID_KEY, string.Empty)) + && !string.IsNullOrEmpty(settings.GetValueOrDefault(WSP.SystemSettings.TWILIO_AUTHTOKEN_KEY, string.Empty)) + && !string.IsNullOrEmpty(settings.GetValueOrDefault(WSP.SystemSettings.TWILIO_PHONEFROM_KEY, string.Empty)); + + rbtnMobile.Visible = twilioEnabled; } protected void btnResetPassoword_Click(object sender, EventArgs e) @@ -54,7 +64,7 @@ namespace WebsitePanel.Portal.ExchangeServer return; } - if (chkDontSaveAsMobile.Checked == false) + if (chkSaveAsMobile.Checked) { OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, PanelRequest.AccountID); diff --git a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserResetPassword.ascx.designer.cs b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserResetPassword.ascx.designer.cs index f0d3eba0..a7c42fa5 100644 --- a/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserResetPassword.ascx.designer.cs +++ b/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/ExchangeServer/OrganizationUserResetPassword.ascx.designer.cs @@ -148,13 +148,13 @@ namespace WebsitePanel.Portal.ExchangeServer { protected global::System.Web.UI.WebControls.TextBox txtMobile; /// - /// chkDontSaveAsMobile control. + /// chkSaveAsMobile control. /// /// /// Auto-generated field. /// To modify move field declaration from designer file to code-behind file. /// - protected global::System.Web.UI.WebControls.CheckBox chkDontSaveAsMobile; + protected global::System.Web.UI.WebControls.CheckBox chkSaveAsMobile; /// /// valMobile control.