Exemple #1
0
        private JwtSecurityToken GetToken(User user)
        {
            // Build the claims based on the user information.
            var claims = new [] {
                // The "NameIdentifier" claim is required to enable retrieving a user
                // based on the HttpContext.User claim principle using the user manager.
                new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()),
                new Claim(ClaimTypes.Name, user.UserName),
                new Claim(ClaimTypes.Email, user.Email),
            };

            // Create a security token for given claims and configuration.
            return(JwtTokenHelper.CreateSecurityToken(claims, configuration));
        }