protected virtual async Task <IEnumerable <Claim> > GetClaimsFromAccount(TUser user) { var claims = new List <Claim> { new Claim(Constants.ClaimTypes.Subject, user.Id.ToString()), new Claim(Constants.ClaimTypes.PreferredUserName, user.UserName), }; if (userManager.SupportsUserEmail) { var email = await userManager.GetEmailAsync(user.Id); if (!String.IsNullOrWhiteSpace(email)) { claims.Add(new Claim(Constants.ClaimTypes.Email, email)); var verified = await userManager.IsEmailConfirmedAsync(user.Id); claims.Add(new Claim(Constants.ClaimTypes.EmailVerified, verified ? "true" : "false")); } } if (userManager.SupportsUserPhoneNumber) { var phone = await userManager.GetPhoneNumberAsync(user.Id); if (!String.IsNullOrWhiteSpace(phone)) { claims.Add(new Claim(Constants.ClaimTypes.PhoneNumber, phone)); var verified = await userManager.IsPhoneNumberConfirmedAsync(user.Id); claims.Add(new Claim(Constants.ClaimTypes.PhoneNumberVerified, verified ? "true" : "false")); } } if (userManager.SupportsUserClaim) { claims.AddRange(await userManager.GetClaimsAsync(user.Id)); } if (userManager.SupportsUserRole) { var roleClaims = from role in await userManager.GetRolesAsync(user.Id) select new Claim(Constants.ClaimTypes.Role, role); claims.AddRange(roleClaims); } return(claims); }