我看到User.IsInRole
周围的几个问题/答案无效,但所有修复都需要手动完成。使用Google身份验证时,只需处理所有内容。
这不起作用:
User.IsInRole( "Admin" )
这确实有效:
var user = await UserManager.GetUserAsync( User );
var isAdmin = await UserManager.IsInRoleAsync( user, "Admin" );
使用Google身份验证使User.IsInRole
方案有效时,我该怎么办?
我按照这两个文档来启用Google身份验证。
https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/ https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins
答案 0 :(得分:0)
为了他人的利益而发帖,此后我浪费了整整一个。发生这种情况的原因有两个: