public IActionResult Post([FromBody][Required] LoginVM login) { try { IActionResult response = Unauthorized(); if (!ModelState.IsValid) { return(BadRequest(new ResponseVM("User name or password must be enterd."))); } Crypto crypto = new Crypto(CryptoTypes.encTypeTripleDES); login.Password = crypto.Encrypt(login.Password); var user = _token.AuthenticateUser(login); if (user != null) { var tokenString = _token.GenerateJSONWebToken(user); response = Ok(new ResponseVM(hasError: false, data: new { token = tokenString })); } else { return(NotFound(new ResponseVM("User not found"))); } return(response); } catch (Exception ex) { _logger.LogError("Invalid user object sent from client.Exception:" + ex.Message ?? ""); return(StatusCode(500, new ResponseVM("Internal server error"))); } }