From 63a2a155d116ed2620705eec696a94ef5021f797 Mon Sep 17 00:00:00 2001 From: agrath Date: Mon, 1 Oct 2018 02:03:52 +1300 Subject: [PATCH] User invite flow review (#3000) --- .../Security/BackOfficeUserManager.cs | 6 +++- .../Security/BackOfficeUserStore.cs | 4 ++- .../views/common/dialogs/login.controller.js | 3 ++ .../src/views/common/dialogs/login.html | 12 +++++-- src/Umbraco.Web.UI/umbraco/config/lang/en.xml | 3 +- .../umbraco/config/lang/en_us.xml | 3 +- .../Editors/AuthenticationController.cs | 32 +++++++++++++++++-- .../Editors/BackOfficeController.cs | 21 ++++++++---- 8 files changed, 70 insertions(+), 14 deletions(-) diff --git a/src/Umbraco.Core/Security/BackOfficeUserManager.cs b/src/Umbraco.Core/Security/BackOfficeUserManager.cs index 83db1a8904..fde188ff27 100644 --- a/src/Umbraco.Core/Security/BackOfficeUserManager.cs +++ b/src/Umbraco.Core/Security/BackOfficeUserManager.cs @@ -236,7 +236,10 @@ namespace Umbraco.Core.Security if (dataProtectionProvider != null) { - manager.UserTokenProvider = new DataProtectorTokenProvider(dataProtectionProvider.Create("ASP.NET Identity")); + manager.UserTokenProvider = new DataProtectorTokenProvider(dataProtectionProvider.Create("ASP.NET Identity")) + { + TokenLifespan = TimeSpan.FromDays(3) + }; } manager.UserLockoutEnabledByDefault = true; @@ -748,6 +751,7 @@ namespace Umbraco.Core.Security var httpContext = HttpContext.Current == null ? (HttpContextBase)null : new HttpContextWrapper(HttpContext.Current); return httpContext.GetCurrentRequestIpAddress(); } + } } diff --git a/src/Umbraco.Core/Security/BackOfficeUserStore.cs b/src/Umbraco.Core/Security/BackOfficeUserStore.cs index e0b91ce175..c6e3399b73 100644 --- a/src/Umbraco.Core/Security/BackOfficeUserStore.cs +++ b/src/Umbraco.Core/Security/BackOfficeUserStore.cs @@ -630,7 +630,9 @@ namespace Umbraco.Core.Security || identityUser.LastLoginDateUtc.HasValue && user.LastLoginDate.ToUniversalTime() != identityUser.LastLoginDateUtc.Value) { anythingChanged = true; - user.LastLoginDate = identityUser.LastLoginDateUtc.Value.ToLocalTime(); + //if the LastLoginDate is being set to MinValue, don't convert it ToLocalTime + var dt = identityUser.LastLoginDateUtc == DateTime.MinValue ? DateTime.MinValue : identityUser.LastLoginDateUtc.Value.ToLocalTime(); + user.LastLoginDate = dt; } if (identityUser.IsPropertyDirty("LastPasswordChangeDateUtc") || (user.LastPasswordChangeDate != default(DateTime) && identityUser.LastPasswordChangeDateUtc.HasValue == false) diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js index 3f50926b47..9b703a0987 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.controller.js @@ -29,6 +29,7 @@ function init() { // Check if it is a new user var inviteVal = $location.search().invite; + //1 = enter password, 2 = password set, 3 = invalid token if (inviteVal && (inviteVal === "1" || inviteVal === "2")) { $q.all([ @@ -58,6 +59,8 @@ $scope.inviteStep = Number(inviteVal); }); + } else if (inviteVal && inviteVal === "3") { + $scope.inviteStep = Number(inviteVal); } } diff --git a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html index b4e330c13e..3b48bcc9f1 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html +++ b/src/Umbraco.Web.UI.Client/src/views/common/dialogs/login.html @@ -99,10 +99,18 @@ - + +