initial commit

This commit is contained in:
2026-07-21 14:28:43 +07:00
commit 01107db6fd
995 changed files with 75124 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
using Indotalent.Data.Entities;
using Indotalent.Infrastructure.Authentication.Identity;
using Microsoft.IdentityModel.Tokens;
using System.IdentityModel.Tokens.Jwt;
using System.Security.Claims;
using System.Text;
namespace Indotalent.ConfigFrontEnd.Service;
public static class JwtService
{
public static string GenerateNewJwt(ApplicationUser user, JwtSettingsModel _jwtSettings)
{
var authClaims = new List<Claim>
{
new(ClaimTypes.Name, user.UserName ?? ""),
new(ClaimTypes.Email, user.Email ?? ""),
new(ClaimTypes.NameIdentifier, user.Id),
new(ClaimTypes.GivenName, user.FullName ?? ""),
new(JwtRegisteredClaimNames.Jti, Guid.NewGuid().ToString()),
};
var authSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_jwtSettings.Key));
var token = new JwtSecurityToken(
issuer: _jwtSettings.Issuer,
audience: _jwtSettings.Audience,
expires: DateTime.Now.AddMinutes(_jwtSettings.DurationInMinutes),
claims: authClaims,
signingCredentials: new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256)
);
return new JwtSecurityTokenHandler().WriteToken(token);
}
}