Set AuthenticationMethod for first Identity external login (#18296)
This commit is contained in:
parent
c5dd4ce7e3
commit
ccf3c4e6b8
|
|
@ -215,7 +215,7 @@ namespace Microsoft.AspNetCore.Identity.UI.V3.Pages.Account.Internal
|
|||
return RedirectToPage("./RegisterConfirmation", new { Email = Input.Email });
|
||||
}
|
||||
|
||||
await _signInManager.SignInAsync(user, isPersistent: false);
|
||||
await _signInManager.SignInAsync(user, isPersistent: false, info.LoginProvider);
|
||||
|
||||
return LocalRedirect(returnUrl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ namespace Microsoft.AspNetCore.Identity.UI.V4.Pages.Account.Internal
|
|||
return RedirectToPage("./RegisterConfirmation", new { Email = Input.Email });
|
||||
}
|
||||
|
||||
await _signInManager.SignInAsync(user, isPersistent: false);
|
||||
await _signInManager.SignInAsync(user, isPersistent: false, info.LoginProvider);
|
||||
return LocalRedirect(returnUrl);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System;
|
||||
using System.Security.Claims;
|
||||
using System.Threading.Tasks;
|
||||
using Identity.DefaultUI.WebSite;
|
||||
using Microsoft.AspNetCore.Identity.UI.Services;
|
||||
|
|
@ -218,5 +219,31 @@ namespace Microsoft.AspNetCore.Identity.FunctionalTests
|
|||
// Act & Assert
|
||||
await UserStories.RegisterNewUserWithSocialLoginAsync(client, userName, email);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RegisterWithASocialLoginProviderSetsAuthenticationMethodClaim()
|
||||
{
|
||||
// Arrange
|
||||
string authenticationMethod = null;
|
||||
|
||||
void ConfigureTestServices(IServiceCollection services) =>
|
||||
services
|
||||
.SetupTestThirdPartyLogin()
|
||||
.SetupGetUserClaimsPrincipal(user =>
|
||||
authenticationMethod = user.FindFirstValue(ClaimTypes.AuthenticationMethod), IdentityConstants.ApplicationScheme);
|
||||
|
||||
var client = ServerFactory
|
||||
.WithWebHostBuilder(whb => whb.ConfigureServices(ConfigureTestServices))
|
||||
.CreateClient();
|
||||
|
||||
var guid = Guid.NewGuid();
|
||||
var userName = $"{guid}";
|
||||
var email = $"{guid}@example.com";
|
||||
|
||||
// Act & Assert
|
||||
await UserStories.RegisterNewUserWithSocialLoginAsync(client, userName, email);
|
||||
|
||||
Assert.Equal("Contoso", authenticationMethod);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue