diff --git a/Site/App_GlobalResources/Global.designer.cs b/Site/App_GlobalResources/Global.designer.cs index cbbfcb8c..a5baaf3c 100644 --- a/Site/App_GlobalResources/Global.designer.cs +++ b/Site/App_GlobalResources/Global.designer.cs @@ -690,6 +690,33 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Two-factor authentication. + /// + internal static string Global_2FA { + get { + return ResourceManager.GetString("Global_2FA", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Two-factor auth. + /// + internal static string Global_2FA_Short { + get { + return ResourceManager.GetString("Global_2FA_Short", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 2FA. + /// + internal static string Global_2FA_Shorter { + get { + return ResourceManager.GetString("Global_2FA_Shorter", resourceCulture); + } + } + /// /// Looks up a localized string similar to Action. /// @@ -1500,6 +1527,15 @@ namespace Resources { } } + /// + /// Looks up a localized string similar to Two-factor authentication was not removed and is still active.. + /// + internal static string Master_EditPerson2FAEnable_NotRemoved { + get { + return ResourceManager.GetString("Master_EditPerson2FAEnable_NotRemoved", resourceCulture); + } + } + /// /// Looks up a localized string similar to Account. /// diff --git a/Site/App_GlobalResources/Global.resx b/Site/App_GlobalResources/Global.resx index 46c178cc..635ae34d 100644 --- a/Site/App_GlobalResources/Global.resx +++ b/Site/App_GlobalResources/Global.resx @@ -774,6 +774,15 @@ A password reset link was sent to this user. + + Two-factor authentication + + + Two-factor auth + + + 2FA + <strong>CANNOT PROVISION 2FA</strong><br/><br/>You cannot turn on two-factor authentication for someone else. They must do it by themselves, thereby being alone in having their secret keys. Displayed when somebody tries to turn on 2FA for someone else. @@ -792,6 +801,9 @@ <strong>REMOVE TWO-FACTOR AUTHENTICATION?</strong><br/><br/>Only do this if you have been requested to turn off 2FA for this user, by this user themselves, <strong>and</strong> you are absolutely, positively sure that the request came from the person whose security you are disabling (as per the verification policy of the organization).<br/><br/>Proceed with removing this user's security? They will fall back to password-only security. Displayed when removing 2FA for someone else + + Two-factor authentication was not removed and is still active. + One day diff --git a/Site/Controls/v5/Base/AjaxTextBox.ascx b/Site/Controls/v5/Base/AjaxTextBox.ascx index 20e2d846..d9d915f3 100644 --- a/Site/Controls/v5/Base/AjaxTextBox.ascx +++ b/Site/Controls/v5/Base/AjaxTextBox.ascx @@ -7,7 +7,18 @@ var _initVal_<%=this.TextInput.ClientID%> = $('#<%=this.TextInput.ClientID%>').val(); $(document).ready(function () { + $('#<%=this.TextInput.ClientID%>').keydown(function (e) { + // reset timer if set + if (<%=this.ClientID%>_onChangingTimer != null) { + clearTimeout(<%=this.ClientID%>_onChangingTimer); + <%=this.ClientID%>_onChangingTimer = setTimeout(function() { <%=this.ClientID%>_fireOnChanging(); }, 500); + } else { + // otherwise set new timer with a more generous timeout on keydown in general + <%=this.ClientID%>_onChangingTimer = setTimeout(function () { <%=this.ClientID%>_fireOnChanging(); }, 500); + } + }); + // OnChange event, AjaxCallback event $('#<%=this.TextInput.ClientID%>').blur(function() { var currentValue = $('#<%=this.TextInput.ClientID%>').val(); @@ -82,6 +93,21 @@ }); + function <%=this.ClientID%>_fireOnChanging() { + <%=this.ClientID%>_onChangingTimer = null; + + alertify.log("FireOnChanging"); + + <% + if (string.IsNullOrEmpty(this.OnChanging)) + { + Response.Write(this.OnChanging + "(" + this.TextInput.ClientID + ".val(), '" + this.Cookie + "', '" + this.ClientID + "');"); // cookie may be empty and that's ok + } + %> + } + + var <%=this.ClientID%>_onChangingTimer = null; + function <%=this.ClientID%>_updateSuccessAnimate(newValue) { $('#<%=this.TextInput.ClientID%>').css('background-color', '#E0FFE0'); $('#<%=this.TextInput.ClientID%>').animate({ backgroundColor: "#FFFFFF" }, 500); diff --git a/Site/Controls/v5/Base/AjaxTextBox.ascx.cs b/Site/Controls/v5/Base/AjaxTextBox.ascx.cs index cee98d41..93cac768 100644 --- a/Site/Controls/v5/Base/AjaxTextBox.ascx.cs +++ b/Site/Controls/v5/Base/AjaxTextBox.ascx.cs @@ -28,6 +28,7 @@ namespace Swarmops.Frontend.Controls.Base public string Cookie { set; get; } public string OnChange { get; set; } + public string OnChanging { get; set; } public string AjaxCallbackUrl { set; get; } public string CssClass diff --git a/Site/Master-v5.master b/Site/Master-v5.master index 36aa3e74..f648b3c9 100644 --- a/Site/Master-v5.master +++ b/Site/Master-v5.master @@ -245,16 +245,22 @@
- +
+ Type current password to enable changes
+ +
+

PERSONNAME:

@@ -355,6 +361,9 @@ // This JavaScript block is for the Master Modal Person Editor. + $(document).ready(function() { + }); + function masterBeginEditPerson(personId) { _master_PersonEditedId = personId; @@ -369,6 +378,8 @@ $('span.spanModalEditingPersonName').text(SwarmopsJS.unescape('<%= this.Localized_LoadingPlaceholderShort %>')); + $('div.divMasterPersonEditSecurityRolldown').hide(); + // Open the Modal <%=this.ModalMasterEditPerson.ClientID%>_open(); @@ -391,6 +402,8 @@ <%= this.MasterEditPersonPhone.ClientID %>_initialize(data.Phone); <%= this.MasterEditPersonTwitterId.ClientID %>_initialize(data.TwitterId); + <%=this.MasterEditPerson2FAProvisioning.ClientID %>_initialize(true); // TODO: Based on data.2FA + _master_PersonEditLoading = false; } else { @@ -422,10 +435,40 @@ <%= this.MasterEditPerson2FAProvisioning.ClientID %>_initialize(false); alertify.alert(SwarmopsJS.unescape('<%=this.Localized_MasterPersonEdit_CannotProvision2FA%>')); } else { - // We're turning 2FA _OFF_ for someone else - are we really sure we want to do this? + alertify.confirm(SwarmopsJS.unescape('<%=this.Localized_MasterPersonEdit_ConfirmRemove2FAProvision%>'), + function (response) { + if (response) { + alert("Success!"); + } else { + <%= this.MasterEditPerson2FAProvisioning.ClientID %>_initialize(true); + alertify.log(SwarmopsJS.unescape('<%=this.Localized_MasterPersonEdit_Cancelled2FARemoval%>')); + } + }); } } + function masterPersonEditor2FAToggle(newValue, fieldName, controlName) { + if (newValue) { // it's a boolean, so "if true" meaning if the slider is "on" + // The user is requesting to enable 2FA. For now, we only use BitId. + + <%= this.MasterEditPerson2FAProvisioning.ClientID %>_initialize(false); + alertify.alert(SwarmopsJS.unescape('<%=this.Localized_MasterPersonEdit_CannotProvision2FA%>')); + } else { + // The user is requesting their 2FA be removed + alertify.confirm(SwarmopsJS.unescape('<%=this.Localized_MasterPersonEdit_ConfirmRemove2FAOwn%>'), + function (response) { + if (response) { + // TODO: Enter password as a security measure (or check against entered) + alert("Success!"); + } else { + <%= this.MasterEditPerson2FAProvisioning.ClientID %>_initialize(true); + alertify.log(SwarmopsJS.unescape('<%=this.Localized_MasterPersonEdit_Cancelled2FARemoval%>')); + } + }); + } + } + + function masterPersonEditorOnFieldChange(newValue, fieldName, controlName) { // Do the AJAX call from here, as we need to also pass along the person ID of the person edited @@ -490,7 +533,7 @@ if (response) { alert("Success!"); } else { - alert("Cancel"); + // Possibly notify user in small log format that cancellation is acknowledged } }); } diff --git a/Site/Master-v5.master.cs b/Site/Master-v5.master.cs index bd47a9f2..58ffc288 100644 --- a/Site/Master-v5.master.cs +++ b/Site/Master-v5.master.cs @@ -478,5 +478,10 @@ namespace Swarmops.Frontend { get { return CommonV5.JavascriptEscape(Resources.Global.Master_EditPerson2FAEnable_ConfirmRemoveOwn); } } + + public string Localized_MasterPersonEdit_Cancelled2FARemoval + { + get { return CommonV5.JavascriptEscape(Resources.Global.Master_EditPerson2FAEnable_NotRemoved); } + } } } \ No newline at end of file diff --git a/Site/Master-v5.master.designer.cs b/Site/Master-v5.master.designer.cs index 6416d733..5b9ae661 100644 --- a/Site/Master-v5.master.designer.cs +++ b/Site/Master-v5.master.designer.cs @@ -363,6 +363,51 @@ namespace Swarmops.Frontend { /// protected global::System.Web.UI.WebControls.Label MasterLabelEditPersonTwitter; + /// + /// MasterLabelEditPersonHeaderSecurity control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::System.Web.UI.WebControls.Label MasterLabelEditPersonHeaderSecurity; + + /// + /// MasterEditPersonCurrentPassword control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Swarmops.Frontend.Controls.Base.AjaxTextBox MasterEditPersonCurrentPassword; + + /// + /// MasterEditPerson2FA control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Swarmops.Frontend.Controls.Base.AjaxToggleSlider MasterEditPerson2FA; + + /// + /// MasterEditPersonNewPassword1 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Swarmops.Frontend.Controls.Base.AjaxTextBox MasterEditPersonNewPassword1; + + /// + /// MasterEditPersonNewPassword2 control. + /// + /// + /// Auto-generated field. + /// To modify move field declaration from designer file to code-behind file. + /// + protected global::Swarmops.Frontend.Controls.Base.AjaxTextBox MasterEditPersonNewPassword2; + /// /// MasterLabelEditPersonHeaderSecurityProvisioning control. ///