twilio fix

This commit is contained in:
vfedosevich 2015-05-04 00:53:56 -07:00
parent d022ecf960
commit 70c772cd3b
8 changed files with 127 additions and 45 deletions

View file

@ -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.
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// <auto-generated> // <auto-generated>
// This code was generated by a tool. // 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 // Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated. // 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 { namespace WebsitePanel.EnterpriseServer {
using System.Diagnostics; using System.Xml.Serialization;
using System.Web.Services; using System.Web.Services;
using System.ComponentModel; using System.ComponentModel;
using System.Web.Services.Protocols; using System.Web.Services.Protocols;
using System; using System;
using System.Xml.Serialization; using System.Diagnostics;
/// <remarks/> /// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.Diagnostics.DebuggerStepThroughAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")] [System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Web.Services.WebServiceBindingAttribute(Name="esSystemSoap", Namespace="http://tempuri.org/")] [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 GetSystemSettingsOperationCompleted;
private System.Threading.SendOrPostCallback GetSystemSettingsActiveOperationCompleted;
private System.Threading.SendOrPostCallback SetSystemSettingsOperationCompleted; private System.Threading.SendOrPostCallback SetSystemSettingsOperationCompleted;
/// <remarks/> /// <remarks/>
public esSystem() { public esSystem() {
this.Url = "http://localhost/EnterpriseServer/esSystem.asmx"; this.Url = "http://localhost:9002/esSystem.asmx";
} }
/// <remarks/> /// <remarks/>
public event GetSystemSettingsCompletedEventHandler GetSystemSettingsCompleted; public event GetSystemSettingsCompletedEventHandler GetSystemSettingsCompleted;
/// <remarks/>
public event GetSystemSettingsActiveCompletedEventHandler GetSystemSettingsActiveCompleted;
/// <remarks/> /// <remarks/>
public event SetSystemSettingsCompletedEventHandler SetSystemSettingsCompleted; public event SetSystemSettingsCompletedEventHandler SetSystemSettingsCompleted;
@ -111,6 +88,50 @@ namespace WebsitePanel.EnterpriseServer {
} }
} }
/// <remarks/>
[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]));
}
/// <remarks/>
public System.IAsyncResult BeginGetSystemSettingsActive(string settingsName, bool decrypt, System.AsyncCallback callback, object asyncState) {
return this.BeginInvoke("GetSystemSettingsActive", new object[] {
settingsName,
decrypt}, callback, asyncState);
}
/// <remarks/>
public SystemSettings EndGetSystemSettingsActive(System.IAsyncResult asyncResult) {
object[] results = this.EndInvoke(asyncResult);
return ((SystemSettings)(results[0]));
}
/// <remarks/>
public void GetSystemSettingsActiveAsync(string settingsName, bool decrypt) {
this.GetSystemSettingsActiveAsync(settingsName, decrypt, null);
}
/// <remarks/>
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));
}
}
/// <remarks/> /// <remarks/>
[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)] [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) { public int SetSystemSettings(string settingsName, SystemSettings settings) {
@ -162,11 +183,11 @@ namespace WebsitePanel.EnterpriseServer {
} }
/// <remarks/> /// <remarks/>
[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); public delegate void GetSystemSettingsCompletedEventHandler(object sender, GetSystemSettingsCompletedEventArgs e);
/// <remarks/> /// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.Diagnostics.DebuggerStepThroughAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")] [System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class GetSystemSettingsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { public partial class GetSystemSettingsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
@ -188,11 +209,37 @@ namespace WebsitePanel.EnterpriseServer {
} }
/// <remarks/> /// <remarks/>
[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);
/// <remarks/>
[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;
}
/// <remarks/>
public SystemSettings Result {
get {
this.RaiseExceptionIfNecessary();
return ((SystemSettings)(this.results[0]));
}
}
}
/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
public delegate void SetSystemSettingsCompletedEventHandler(object sender, SetSystemSettingsCompletedEventArgs e); public delegate void SetSystemSettingsCompletedEventHandler(object sender, SetSystemSettingsCompletedEventArgs e);
/// <remarks/> /// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.42")] [System.CodeDom.Compiler.GeneratedCodeAttribute("wsdl", "2.0.50727.3038")]
[System.Diagnostics.DebuggerStepThroughAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")] [System.ComponentModel.DesignerCategoryAttribute("code")]
public partial class SetSystemSettingsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs { public partial class SetSystemSettingsCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {

View file

@ -53,6 +53,18 @@ namespace WebsitePanel.EnterpriseServer
return GetSystemSettingsInternal(settingsName, !isDemoAccount); 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) internal static SystemSettings GetSystemSettingsInternal(string settingsName, bool decryptPassword)
{ {
// create settings object // create settings object

View file

@ -53,6 +53,12 @@ namespace WebsitePanel.EnterpriseServer
return SystemController.GetSystemSettings(settingsName); return SystemController.GetSystemSettings(settingsName);
} }
[WebMethod]
public SystemSettings GetSystemSettingsActive(string settingsName, bool decrypt)
{
return SystemController.GetSystemSettingsActive(settingsName, decrypt);
}
[WebMethod] [WebMethod]
public int SetSystemSettings(string settingsName, SystemSettings settings) public int SetSystemSettings(string settingsName, SystemSettings settings)
{ {

View file

@ -208,7 +208,14 @@ namespace WebsitePanel.WebDavPortal.Controllers
var user = WspContext.Services.Organizations.GetUserGeneralSettings(accessToken.ItemId, accessToken.AccountId); 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); var result = WspContext.Services.Organizations.SendResetUserPasswordPincodeEmail(accessToken.AccessTokenGuid, user.PrimaryEmailAddress);

View file

@ -120,8 +120,8 @@
<data name="btnResetPassoword.Text" xml:space="preserve"> <data name="btnResetPassoword.Text" xml:space="preserve">
<value>Send Password Reset Email</value> <value>Send Password Reset Email</value>
</data> </data>
<data name="chkDontSaveAsMobile.Text" xml:space="preserve"> <data name="chkSaveAsMobile.Text" xml:space="preserve">
<value>Don't save as user mobile</value> <value>Save as user mobile</value>
</data> </data>
<data name="locEmailAddress.Text" xml:space="preserve"> <data name="locEmailAddress.Text" xml:space="preserve">
<value>Email:</value> <value>Email:</value>

View file

@ -45,7 +45,7 @@
<asp:Localize ID="locMobile" runat="server" meta:resourcekey="locMobile"></asp:Localize></td> <asp:Localize ID="locMobile" runat="server" meta:resourcekey="locMobile"></asp:Localize></td>
<td> <td>
<asp:TextBox runat="server" ID="txtMobile" CssClass="TextBox200" /> <asp:TextBox runat="server" ID="txtMobile" CssClass="TextBox200" />
<asp:CheckBox ID="chkDontSaveAsMobile" runat="server" Text="Don't save as mobile" meta:resourcekey="chkDontSaveAsMobile" Checked="True" /> <asp:CheckBox ID="chkSaveAsMobile" runat="server" Text="Save as mobile" meta:resourcekey="chkSaveAsMobile" Checked="False" />
<asp:RequiredFieldValidator ID="valMobile" runat="server" ErrorMessage="*" ControlToValidate="txtMobile" ValidationGroup="ResetUserPassword"></asp:RequiredFieldValidator> <asp:RequiredFieldValidator ID="valMobile" runat="server" ErrorMessage="*" ControlToValidate="txtMobile" ValidationGroup="ResetUserPassword"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regexMobileValid" runat="server" ValidationExpression="^\+?\d+$" ValidationGroup="ResetUserPassword" ControlToValidate="txtMobile" ErrorMessage="Invalid Mobile Format"></asp:RegularExpressionValidator> <asp:RegularExpressionValidator ID="regexMobileValid" runat="server" ValidationExpression="^\+?\d+$" ValidationGroup="ResetUserPassword" ControlToValidate="txtMobile" ErrorMessage="Invalid Mobile Format"></asp:RegularExpressionValidator>
</td> </td>

View file

@ -5,6 +5,7 @@ using System.Web;
using System.Web.UI; using System.Web.UI;
using System.Web.UI.WebControls; using System.Web.UI.WebControls;
using WebsitePanel.Providers.HostedSolution; using WebsitePanel.Providers.HostedSolution;
using WSP = WebsitePanel.EnterpriseServer;
namespace WebsitePanel.Portal.ExchangeServer namespace WebsitePanel.Portal.ExchangeServer
{ {
@ -28,6 +29,15 @@ namespace WebsitePanel.Portal.ExchangeServer
txtEmailAddress.Text = user.PrimaryEmailAddress; txtEmailAddress.Text = user.PrimaryEmailAddress;
txtMobile.Text = user.MobilePhone; 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) protected void btnResetPassoword_Click(object sender, EventArgs e)
@ -54,7 +64,7 @@ namespace WebsitePanel.Portal.ExchangeServer
return; return;
} }
if (chkDontSaveAsMobile.Checked == false) if (chkSaveAsMobile.Checked)
{ {
OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID, OrganizationUser user = ES.Services.Organizations.GetUserGeneralSettings(PanelRequest.ItemID,
PanelRequest.AccountID); PanelRequest.AccountID);

View file

@ -148,13 +148,13 @@ namespace WebsitePanel.Portal.ExchangeServer {
protected global::System.Web.UI.WebControls.TextBox txtMobile; protected global::System.Web.UI.WebControls.TextBox txtMobile;
/// <summary> /// <summary>
/// chkDontSaveAsMobile control. /// chkSaveAsMobile control.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Auto-generated field. /// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file. /// To modify move field declaration from designer file to code-behind file.
/// </remarks> /// </remarks>
protected global::System.Web.UI.WebControls.CheckBox chkDontSaveAsMobile; protected global::System.Web.UI.WebControls.CheckBox chkSaveAsMobile;
/// <summary> /// <summary>
/// valMobile control. /// valMobile control.