diff --git a/Common/Enums/ObjectOptionalDataType.cs b/Common/Enums/ObjectOptionalDataType.cs
index 2add12f7..a2dd3b9d 100644
--- a/Common/Enums/ObjectOptionalDataType.cs
+++ b/Common/Enums/ObjectOptionalDataType.cs
@@ -329,7 +329,7 @@ namespace Swarmops.Common.Enums
BitcoinPayoutAddress,
///
- /// When the bitcoin address was set (to enable quarantine)
+ /// When the bitcoin address was set (to enable payout quarantine)
///
BitcoinPayoutAddressTimeSet,
@@ -381,6 +381,21 @@ namespace Swarmops.Common.Enums
///
/// When (if) the org pays taxes, what number to put on the payment to identify the sender
///
- OrgTaxPaymentOcr
+ OrgTaxPaymentOcr,
+
+ ///
+ /// Prohibit any financial payouts or withdrawals before this time (UTC).
+ ///
+ QuarantineWithdrawalsUntil,
+
+ ///
+ /// Prohibit any login before this time (UTC).
+ ///
+ QuarantineLoginsUntil,
+
+ ///
+ /// Prohibit all active sessions until this time (UTC).
+ ///
+ QuarantineSessionsUntil
}
}
\ No newline at end of file
diff --git a/Logic/Logic.csproj b/Logic/Logic.csproj
index 3a81241d..2c377a7a 100644
--- a/Logic/Logic.csproj
+++ b/Logic/Logic.csproj
@@ -409,6 +409,8 @@
+
+
diff --git a/Logic/Swarm/Person.cs b/Logic/Swarm/Person.cs
index 89ab70ac..c601695a 100644
--- a/Logic/Swarm/Person.cs
+++ b/Logic/Swarm/Person.cs
@@ -1181,6 +1181,15 @@ namespace Swarmops.Logic.Swarm
return Volunteer.Create (this);
}
+
+ public PersonQuarantines Quarantines
+ {
+ get
+ {
+ return new PersonQuarantines(this);
+ }
+ }
+
// A couple of special cases
public const int OpenLedgersIdentity = -1;
diff --git a/Logic/Swarm/PersonQuarantine.cs b/Logic/Swarm/PersonQuarantine.cs
new file mode 100644
index 00000000..6bf9013d
--- /dev/null
+++ b/Logic/Swarm/PersonQuarantine.cs
@@ -0,0 +1,53 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Swarmops.Common.Enums;
+using Swarmops.Logic.Support;
+
+namespace Swarmops.Logic.Swarm
+{
+ public class PersonQuarantine
+ {
+ internal PersonQuarantine(Person person, ObjectOptionalDataType quarantineType) // internal: can only be constructed in assembly
+ {
+ this._person = person;
+ this._quarantineType = quarantineType;
+ }
+
+ public DateTime UntilWhen
+ {
+ get
+ {
+ string quarantineString = ObjectOptionalData.ForObject(this._person).GetOptionalDataString(this._quarantineType);
+
+ if (quarantineString.Length > 0)
+ {
+ return DateTime.ParseExact(quarantineString, "yyyy-MM-dd hh:mm:ss", CultureInfo.InvariantCulture);
+ }
+ else
+ {
+ return DateTime.MinValue; // no quarantine active
+ }
+ }
+ }
+
+ public bool IsActive
+ {
+ get { return (this.UntilWhen > DateTime.UtcNow); }
+ }
+
+ public void QuarantineFor(TimeSpan span)
+ {
+ DateTime now = DateTime.UtcNow;
+ DateTime quarantineUntil = now + span;
+
+ ObjectOptionalData.ForObject(this._person).SetOptionalDataString(this._quarantineType, quarantineUntil.ToString("yyyy-MM-dd hh:mm:ss", CultureInfo.InvariantCulture));
+ }
+
+ private Person _person;
+ private ObjectOptionalDataType _quarantineType;
+ }
+}
diff --git a/Logic/Swarm/PersonQuarantines.cs b/Logic/Swarm/PersonQuarantines.cs
new file mode 100644
index 00000000..84e082a9
--- /dev/null
+++ b/Logic/Swarm/PersonQuarantines.cs
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Swarmops.Common.Enums;
+
+namespace Swarmops.Logic.Swarm
+{
+ public class PersonQuarantines
+ {
+ internal PersonQuarantines(Person person) // internal: can only be constructed in assembly
+ {
+ this._person = person;
+ }
+
+ public PersonQuarantine Withdrawal
+ {
+ get { return new PersonQuarantine(this._person, ObjectOptionalDataType.QuarantineWithdrawalsUntil); }
+ }
+
+ public PersonQuarantine Login
+ {
+ get { return new PersonQuarantine(this._person, ObjectOptionalDataType.QuarantineLoginsUntil); }
+ }
+
+ public PersonQuarantine Sessions
+ {
+ get { return new PersonQuarantine(this._person, ObjectOptionalDataType.QuarantineSessionsUntil); }
+ }
+
+ private Person _person;
+ }
+}
diff --git a/Site/App_GlobalResources/Global.designer.cs b/Site/App_GlobalResources/Global.designer.cs
index a5baaf3c..37ba9f54 100644
--- a/Site/App_GlobalResources/Global.designer.cs
+++ b/Site/App_GlobalResources/Global.designer.cs
@@ -1554,6 +1554,33 @@ namespace Resources {
}
}
+ ///
+ /// Looks up a localized string similar to Unable to set new password: The old password is incorrect..
+ ///
+ internal static string Master_EditPersonNewPassword_CannotChange_SecurityError {
+ get {
+ return ResourceManager.GetString("Master_EditPersonNewPassword_CannotChange_SecurityError", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Unable to set new password: The new password is too weak. Use a stronger password..
+ ///
+ internal static string Master_EditPersonNewPassword_CannotChange_TooWeak {
+ get {
+ return ResourceManager.GetString("Master_EditPersonNewPassword_CannotChange_TooWeak", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to <strong>PASSWORD CHANGED</strong><br/><br/>You have successfully changed your password. As a security measure, all withdrawals are now in quarantine for the next 48 hours.<br/><br/>If you can, please enable BitID two-factor authentication..
+ ///
+ internal static string Master_EditPersonNewPassword_Changed {
+ get {
+ return ResourceManager.GetString("Master_EditPersonNewPassword_Changed", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Reset password.
///
diff --git a/Site/App_GlobalResources/Global.resx b/Site/App_GlobalResources/Global.resx
index 635ae34d..cd006cd1 100644
--- a/Site/App_GlobalResources/Global.resx
+++ b/Site/App_GlobalResources/Global.resx
@@ -816,4 +816,13 @@
Two weeks
+
+ Unable to set new password: The old password is incorrect.
+
+
+ Unable to set new password: The new password is too weak. Use a stronger password.
+
+
+ <strong>PASSWORD CHANGED</strong><br/><br/>You have successfully changed your password. As a security measure, all withdrawals are now in quarantine for the next 48 hours.<br/><br/>If you can, please enable BitID two-factor authentication.
+
\ No newline at end of file
diff --git a/Site/Automation/SwarmFunctions.aspx.cs b/Site/Automation/SwarmFunctions.aspx.cs
index f20b0097..f945ab31 100644
--- a/Site/Automation/SwarmFunctions.aspx.cs
+++ b/Site/Automation/SwarmFunctions.aspx.cs
@@ -405,5 +405,59 @@ namespace Swarmops.Frontend.Automation
return authData.CurrentUser.ValidatePassword(password);
}
+
+ [WebMethod]
+ public static AjaxCallResult ChangePassword(int personId, string oldPassword, string newPassword)
+ {
+ if (!ValidatePassword(personId, oldPassword))
+ {
+ // 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
+ };
+ }
+
+ AuthenticationData authData = GetAuthenticationDataAndCulture();
+
+ if (authData.CurrentUser.Identity != personId)
+ {
+ // TODO: Same thing with this case
+
+ return new AjaxCallResult
+ {
+ Success = false,
+ DisplayMessage = Resources.Global.Master_EditPersonNewPassword_CannotChange_SecurityError
+ };
+ }
+
+ if (newPassword.Length < 6) // TODO: Make per-installation and per-organization policy for this
+ {
+ return new AjaxCallResult
+ {
+ Success = false,
+ DisplayMessage = Resources.Global.Master_EditPersonNewPassword_CannotChange_TooWeak
+ };
+ }
+
+ authData.CurrentUser.SetPassword(newPassword);
+ // TODO: LOG
+ // TODO: NOTIFY
+ authData.CurrentUser.Quarantines.Withdrawal.QuarantineFor(new TimeSpan(2, 0, 0, 0)); // Quarantine for two days
+
+ return new AjaxCallResult
+ {
+ Success = true,
+ DisplayMessage = Resources.Global.Master_EditPersonNewPassword_Changed
+ };
+ }
}
}
\ No newline at end of file
diff --git a/Site/Controls/v5/Base/AjaxTextBox.ascx b/Site/Controls/v5/Base/AjaxTextBox.ascx
index 61316c78..282e2931 100644
--- a/Site/Controls/v5/Base/AjaxTextBox.ascx
+++ b/Site/Controls/v5/Base/AjaxTextBox.ascx
@@ -161,6 +161,10 @@
$('#<%=this.TextInput.ClientID%>').val(newValue);
}
+ function <%=this.ClientID%>_val() {
+ return $('#<%=this.TextInput.ClientID%>').val();
+ }
+
function <%=this.ClientID%>_initialize(initValue) {
_initVal_<%=this.TextInput.ClientID%> = initValue;
<%=this.ClientID%>_setValue(initValue);
diff --git a/Site/Master-v5.master b/Site/Master-v5.master
index c6acafe6..ad20ca51 100644
--- a/Site/Master-v5.master
+++ b/Site/Master-v5.master
@@ -250,8 +250,8 @@
@@ -394,6 +394,45 @@
});
}
+ function masterPersonEditorOnSecurityNewPasswordChanging(newValue, cookie, controlName) {
+ if (cookie == "Password2") {
+ // only validate as result of second field. May result in bad UX if somebody fills in fields in wrong order.
+
+ if (newValue == <%=this.MasterEditPersonNewPassword1%>_val() && newValue.length >= 6) // short minimum, but policy settings could override
+ {
+ // Newpasswords match, attempt to change the password
+ <%=this.MasterEditPersonNewPassword1%>_updateProgressAnimate();
+ <%=this.MasterEditPersonNewPassword2%>_updateProgressAnimate();
+
+ var jsonData = {
+ personId: _master_PersonEditedId,
+ oldPassword: <%=this.MasterEditPersonCurrentPassword%>_val(),
+ newPassword: newValue
+ };
+
+ SwarmopsJS.ajaxCall("/Automation/SwarmFunctions.aspx/ChangePassword", jsonData, function(result) {
+ if (result.Success) // if password was changed
+ {
+ if (result.DisplayMessage.length > 0) {
+ alertify.dialog(result.DisplayMessage);
+ }
+ <%=this.MasterEditPersonNewPassword1%>_updateSuccessAnimate();
+ <%=this.MasterEditPersonNewPassword2%>_updateSuccessAnimate();
+ <%=this.MasterEditPersonNewPassword1%>_clear();
+ <%=this.MasterEditPersonNewPassword2%>_clear();
+ <%=this.MasterEditPersonCurrentPassword%>_initialize(newValue); // move new password to current
+ <%=this.MasterEditPersonCurrentPassword%>_updateSuccessAnimate();
+ } else {
+ alertify.error(result.DisplayMessage);
+
+ <%=this.MasterEditPersonNewPassword1%>_updateFailAnimate();
+ <%=this.MasterEditPersonNewPassword2%>_updateFailAnimate();
+ }
+ });
+ }
+ }
+ }
+
function masterBeginEditPerson(personId) {
_master_PersonEditedId = personId;