Hi I need help with asp.net core webapi. please see highlighted code snippet. The highlighted code seem to work fine on my local development machine but does not work on remote ubuntu production server. Please could somebody tell me what is the problem.
[HttpPost("~/Makwada/Token/Authenticate/{username}/{password}")]
public IActionResult Authenticate(string username, string password)
{
string remote = _accessor.HttpContext.Connection.RemoteIpAddress.ToString();
var login = Authenticated(username, password);
if (login == true)
{
return new ObjectResult(GenerateToken(username));
}
else
{
return Unauthorized();
}
}
public bool Authenticated(string username, string password)
{
bool result = false;
string sql = "SELECT Password FROM account WHERE UserName = @UserName ;";
using (IDbConnection dbConnection = Connection)
{
try
{
dbConnection.Open();
DynamicParameters param = new DynamicParameters();
param.Add("@UserName", username);
string text = Convert.ToString(RuntimeHelpers.GetObjectValue(dbConnection.QuerySingleOrDefaultAsync<string> (sql, param, commandType: CommandType.Text).Result));
string right = Crypto.CalculateMD5Hash(password);
result = (Operators.CompareString(text, right, false) == 0);
}
catch (Exception ex)
{
var err = ex.Message;
// p.LogError(ex);
}
finally
{
}
return result;
}
}