JSON Parse Help
How can i fix the problem ?
public async Task<ActionResult<User>> Login(LoginUserDto loginUserDto)
{
var user = await _userService.Login(loginUserDto.Mail, loginUserDto.Password);
if (user == null)
{
return Unauthorized();
}
else
{
await _logService.Add(
new Log
{
Durum = "Başarılı",
Aciklama = "Kullanıcı Giriş Yaptı",
IslemTipi = "Kullanıcı Giriş",
DateTime = DateTime.Now.ToString("yyyy-MM-dd h:mm:ss tt"),
UserIp = HttpContext.Connection.RemoteIpAddress?.ToString(),
}
);
var tokenHandler = new JwtSecurityTokenHandler();
var key = Encoding.ASCII.GetBytes(_configuration.GetSection("Appsettings:Token").Value);
var tokenDescriptor = new SecurityTokenDescriptor
{
Subject = new ClaimsIdentity(new Claim[]
{
new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()),
new Claim(ClaimTypes.Email, user.Mail)
}),
Expires = DateTime.Now.AddDays(1),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha512Signature)
};
var token = tokenHandler.CreateToken(tokenDescriptor);
var tokenString = tokenHandler.WriteToken(token);
return Ok(tokenString);
}
1 Reply
problem fixed