More BitID work

This commit is contained in:
Falkvinge
2016-11-25 17:54:33 +01:00
parent ad187a5f54
commit c64e3a73df
2 changed files with 55 additions and 3 deletions
+40
View File
@@ -495,5 +495,45 @@ namespace Swarmops.Frontend.Automation
}
}
public static AjaxCallResult RemoveBitId(int personId, string password)
{
AuthenticationData authData = GetAuthenticationDataAndCulture();
if (personId == 0) // self
{
personId = authData.CurrentUser.Identity;
if (!ValidatePassword(personId, password))
{
// oldPassword field isn't correct
// TODO: LOG THIS, THIS SHOULD NOT HAPPEN (UI FILTERING THIS CASE)
// TODO: ALSO NOTIFY SECURITY OFFICERS
// TODO: THROTTLE AND BLACKLIST?
return new AjaxCallResult
{
Success = false,
DisplayMessage = Resources.Global.Master_EditPersonNewPassword_CannotChange_SecurityError
};
}
authData.CurrentUser.BitIdAddress = string.Empty;
return new AjaxCallResult {Success = true};
}
else
{
// Validate rights to remove BitId
// Log, notify, and chainnotify
throw new NotImplementedException();
}
}
}
}
+15 -3
View File
@@ -527,10 +527,21 @@
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!");
var jsonData =
{
password: <%=this.MasterEditPersonCurrentPassword.ClientID%>_value()
}
SwarmopsJS.ajaxCall("/Automation/SwarmFunctions.aspx/RemoveBitId", jsonData, function(result) {
if (result.Success) {
// Success: UX feedback is slider in "off" position
} else {
alertify.error(result.DisplayMessage);
<%= this.MasterEditPerson2FA.ClientID %>_initialize(true);
}
});
} else {
<%= this.MasterEditPerson2FAProvisioning.ClientID %>_initialize(true);
<%= this.MasterEditPerson2FA.ClientID %>_initialize(true);
alertify.log(SwarmopsJS.unescape('<%=this.Localized_MasterPersonEdit_Cancelled2FARemoval%>'));
}
});
@@ -650,6 +661,7 @@
function onBitIdRegisterRecheck() {
SwarmopsJS.ajaxCall("/Automation/SwarmFunctions.aspx/TestBitIdRegister", {}, function(result) {
alertify.log(result.Success);
if (result.Success) {
_master_bitIdRecheckTimer = null;
<%=this.ModalMasterEnableBitId%>_close();