Пример #1
0
        public async Task <string> GenerateAccessWithClaims(User user)
        {
            var profile = await _profileManager.GetProfileByIdAsync(user.Id);

            var claims = new List <Claim>
            {
                new Claim("avatar", profile.ImagePath)
            };

            claims.AddRange(from role in await _userManager.GetRolesAsync(user)
                            select new Claim(ClaimsIdentity.DefaultRoleClaimType, role));

            return(await _tokenHandler.GenerateAccessTokenAsync(user, claims));
        }