更新时间:2021-07-10 23:33:51
使用外部提供程序登录时,SignInManager
将类型为http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod
的声明添加到ClaimsPrincipal
(
When signing in using an external provider, SignInManager
adds a claim of type http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod
to the ClaimsPrincipal
(source). You can read this value to determine which provider was used for sign-in.
下面是一些示例代码,您应该可以直接将它们插入HomeController
:
Here's some example code that you should be able to plug in to your HomeController
as is:
var externalProvider = User.FindFirstValue(ClaimTypes.AuthenticationMethod);