ensures the last login date, etc... are updated with external logins
This commit is contained in:
@@ -408,7 +408,9 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
|||||||
if (ViewData.FromBase64CookieData<BackOfficeExternalLoginProviderErrors>(_httpContextAccessor.HttpContext, ViewDataExtensions.TokenExternalSignInError, _jsonSerializer) ||
|
if (ViewData.FromBase64CookieData<BackOfficeExternalLoginProviderErrors>(_httpContextAccessor.HttpContext, ViewDataExtensions.TokenExternalSignInError, _jsonSerializer) ||
|
||||||
ViewData.FromTempData(TempData, ViewDataExtensions.TokenExternalSignInError) ||
|
ViewData.FromTempData(TempData, ViewDataExtensions.TokenExternalSignInError) ||
|
||||||
ViewData.FromTempData(TempData, ViewDataExtensions.TokenPasswordResetCode))
|
ViewData.FromTempData(TempData, ViewDataExtensions.TokenPasswordResetCode))
|
||||||
|
{
|
||||||
return defaultResponse();
|
return defaultResponse();
|
||||||
|
}
|
||||||
|
|
||||||
//First check if there's external login info, if there's not proceed as normal
|
//First check if there's external login info, if there's not proceed as normal
|
||||||
var loginInfo = await _signInManager.GetExternalLoginInfoAsync();
|
var loginInfo = await _signInManager.GetExternalLoginInfoAsync();
|
||||||
@@ -442,12 +444,12 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
|
|||||||
|
|
||||||
var errors = new List<string>();
|
var errors = new List<string>();
|
||||||
|
|
||||||
if (result == Microsoft.AspNetCore.Identity.SignInResult.Success)
|
if (result == SignInResult.Success)
|
||||||
{
|
{
|
||||||
// Update any authentication tokens if succeeded
|
// Update any authentication tokens if succeeded
|
||||||
await _signInManager.UpdateExternalAuthenticationTokensAsync(loginInfo);
|
await _signInManager.UpdateExternalAuthenticationTokensAsync(loginInfo);
|
||||||
}
|
}
|
||||||
else if (result == Microsoft.AspNetCore.Identity.SignInResult.TwoFactorRequired)
|
else if (result == SignInResult.TwoFactorRequired)
|
||||||
{
|
{
|
||||||
|
|
||||||
var attemptedUser = await _userManager.FindByLoginAsync(loginInfo.LoginProvider, loginInfo.ProviderKey);
|
var attemptedUser = await _userManager.FindByLoginAsync(loginInfo.LoginProvider, loginInfo.ProviderKey);
|
||||||
|
|||||||
@@ -198,6 +198,9 @@ namespace Umbraco.Cms.Web.Common.Security
|
|||||||
// code taken from aspnetcore: https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs
|
// code taken from aspnetcore: https://github.com/dotnet/aspnetcore/blob/master/src/Identity/Core/src/SignInManager.cs
|
||||||
// we also override to set the current HttpContext principal since this isn't done by default
|
// we also override to set the current HttpContext principal since this isn't done by default
|
||||||
|
|
||||||
|
// we also need to call our handle login to ensure all date/events are set
|
||||||
|
await HandleSignIn(user, user.UserName, SignInResult.Success);
|
||||||
|
|
||||||
var userPrincipal = await CreateUserPrincipalAsync(user);
|
var userPrincipal = await CreateUserPrincipalAsync(user);
|
||||||
foreach (var claim in additionalClaims)
|
foreach (var claim in additionalClaims)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user