diff --git a/phronCare.API/Controllers/AuthenticationController.cs b/phronCare.API/Controllers/AuthenticationController.cs index 98dca92..2ddaec7 100644 --- a/phronCare.API/Controllers/AuthenticationController.cs +++ b/phronCare.API/Controllers/AuthenticationController.cs @@ -255,8 +255,9 @@ namespace phronCare.API.Controllers { authClaims.Add(new Claim(ClaimTypes.Role, role)); } + var jwtToken = GetToken(authClaims); - /* Returning the User Session object */ + var userSession = new UserSession { UserName = user.UserName, @@ -266,12 +267,6 @@ namespace phronCare.API.Controllers ExpiryTimeStamp = jwtToken.ValidTo }; return Ok(userSession); - /* Returning simple jwt object */ - //return Ok(new - //{ - // token = new JwtSecurityTokenHandler().WriteToken(jwtToken), - // expiration = jwtToken.ValidTo - //}); } public class UserSession { @@ -307,19 +302,6 @@ namespace phronCare.API.Controllers return token; } - - //private JwtSecurityToken GetToken(List authClaims) - //{ - // var authSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(configuration["JWT:Secret"])); - // var token = new JwtSecurityToken( - // issuer: configuration["JWT:ValidIssuer"], - // audience: configuration["JWT:ValidAudience"], - // expires: DateTime.Now.AddHours(JWT_TOKEN_VALIDITY_HOURS), - // claims: authClaims, - // signingCredentials: new SigningCredentials(authSigningKey, SecurityAlgorithms.HmacSha256Signature) - // ); - // return token; - //} #endregion } } \ No newline at end of file diff --git a/phronCare.API/Program.cs b/phronCare.API/Program.cs index b6e8a09..b5ed7b9 100644 --- a/phronCare.API/Program.cs +++ b/phronCare.API/Program.cs @@ -196,6 +196,9 @@ builder.Services.AddCors(options => builder.Services.AddControllers(); builder.Services.AddEndpointsApiExplorer(); +Console.WriteLine($"JWT Issuer: {configuration["JWT:ValidIssuer"]}"); +Console.WriteLine($"JWT Audience: {configuration["JWT:ValidAudience"]}"); + var app = builder.Build(); //if (app.Environment.IsDevelopment())