From cf877e84f3bcf2aa9d431bbac4bfa97aea1c273d Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Thu, 29 Jan 2015 12:37:20 +0100 Subject: [PATCH] Pushing to deploy new backend notifications --- ...ansmission.NotificationPayload.Designer.cs | 6 ++--- ...ions.Transmission.NotificationPayload.resx | 6 ++--- Logic/Communications/OutboundComm.cs | 2 +- Site5/Security/RequestPasswordReset.aspx.cs | 24 +++++++++++++++++-- 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.Designer.cs b/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.Designer.cs index 11ca2921..d2b1ca16 100644 --- a/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.Designer.cs +++ b/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.Designer.cs @@ -379,9 +379,9 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to Somebody, most likely you, requested a reset of the password associated with this email address at [OrganizationName]. However, two-factor authentication has been enabled for this account for heightened security. Therefore, the password CANNOT be reset by simple means. + /// Looks up a localized string similar to Somebody, most likely you, requested a reset of the password associated with this mail address at [InstallationName]. However, two-factor authentication has been enabled for this account for heightened security. Therefore, the password CANNOT be reset by simple means. /// - ///Please contact a personnel administrator at [OrganizationName] to resolve your problem and issue a new password following a more rigorous identification procedure matching the two-factor security level. + ///Please contact a personnel administrator at [InstallationName] to resolve your problem and issue a new password following a more rigorous identification procedure matching the two-factor security level. /// ///Thank you for your understanding.. /// @@ -392,7 +392,7 @@ namespace Swarmops.Logic.App_GlobalResources { } /// - /// Looks up a localized string similar to [[OrganizationName]] Cannot Reset Password. + /// Looks up a localized string similar to [[InstallationName]] Cannot Reset Password. /// internal static string Password_CannotReset2FA_Subject { get { diff --git a/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.resx b/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.resx index a8c29806..72307245 100644 --- a/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.resx +++ b/Logic/App_GlobalResources/Logic.Communications.Transmission.NotificationPayload.resx @@ -244,14 +244,14 @@ Time spent transmitting: [TransmissionTime]. [[OrganizationName]] Comms transmitted: [GeographyName] - Somebody, most likely you, requested a reset of the password associated with this email address at [OrganizationName]. However, two-factor authentication has been enabled for this account for heightened security. Therefore, the password CANNOT be reset by simple means. + Somebody, most likely you, requested a reset of the password associated with this mail address at [InstallationName]. However, two-factor authentication has been enabled for this account for heightened security. Therefore, the password CANNOT be reset by simple means. -Please contact a personnel administrator at [OrganizationName] to resolve your problem and issue a new password following a more rigorous identification procedure matching the two-factor security level. +Please contact a personnel administrator at [InstallationName] to resolve your problem and issue a new password following a more rigorous identification procedure matching the two-factor security level. Thank you for your understanding. - [[OrganizationName]] Cannot Reset Password + [[InstallationName]] Cannot Reset Password Your [InstallationName] password was changed at [ExternalUrl]. diff --git a/Logic/Communications/OutboundComm.cs b/Logic/Communications/OutboundComm.cs index 72c87282..1e0c6623 100644 --- a/Logic/Communications/OutboundComm.cs +++ b/Logic/Communications/OutboundComm.cs @@ -259,7 +259,7 @@ namespace Swarmops.Logic.Communications } - public static OutboundComm CreateSecurityNotifcation (Person concernedPerson, Person actingPerson, Organization organization, string ticket, + public static OutboundComm CreateSecurityNotification (Person concernedPerson, Person actingPerson, Organization organization, string ticket, NotificationResource notification) { NotificationPayload payload = new NotificationPayload(notification.ToString()); diff --git a/Site5/Security/RequestPasswordReset.aspx.cs b/Site5/Security/RequestPasswordReset.aspx.cs index 096b92bf..c00d0bb1 100644 --- a/Site5/Security/RequestPasswordReset.aspx.cs +++ b/Site5/Security/RequestPasswordReset.aspx.cs @@ -1,10 +1,14 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Web; +using System.Web.Configuration; using System.Web.Services; using System.Web.UI; using System.Web.UI.WebControls; +using Swarmops.Logic.Communications; +using Swarmops.Logic.Communications.Transmission; using Swarmops.Logic.Support; using Swarmops.Logic.Swarm; @@ -52,12 +56,28 @@ namespace Swarmops.Pages.Security People concernedPeople = People.FromMail (mailAddress); // Should result in exactly 1 + if (concernedPeople.Count != 1) + { + return true; // TODO: Prevent registration with duplicate mail addy, or this will cause problems down the road + } + + Person concernedPerson = concernedPeople[0]; + + if (!string.IsNullOrEmpty (concernedPerson.BitIdAddress)) + { + // Cannot reset password - two factor auth is enabled. Manual intervention required. + + OutboundComm.CreateSecurityNotification (concernedPerson, null, null, string.Empty, + NotificationResource.Password_CannotReset2FA); + } + string resetTicket = SupportFunctions.GenerateSecureRandomKey (16); // 16 bytes = 128 bits random key, more than good enough + concernedPerson.ResetPasswordTicket = DateTime.UtcNow.AddHours (1).ToString(CultureInfo.InvariantCulture) + "," + resetTicket; // Adds expiry - one hour - - Outbound + OutboundComm.CreateSecurityNotification (concernedPerson, null, null, resetTicket, + NotificationResource.Password_ResetOnRequest); // Create log entry