public async Task <IActionResult> AuthenticateUser(Request <UserModel> request) { IActionResult response; Response <UserModel> responseContent = new Response <UserModel>(); string requestString = JsonConvert.SerializeObject(request); if (request != null && request.Entity != null) { var isValidUser = await service.ValidateUserCredential(request); if (isValidUser != null && isValidUser.ResultSet != null) { var jwt = new JwtTokenService(config); var token = jwt.GenerateSecurityToken(isValidUser.ResultSet); isValidUser.ResultSet.Token = token; isValidUser.ResultSet.Password = ""; responseContent = isValidUser; response = Ok(responseContent); logger.LogInfo(MessageConstant.AUTHENTICATION_SUCCESSFUL + " Request: " + requestString); } else { response = Unauthorized(MessageConstant.AUTHENTICATION_FAILED); logger.LogError(MessageConstant.AUTHENTICATION_FAILED + " Request: " + requestString); } } else { responseContent.AddErrorMessage(MessageConstant.GENERAL_INVALID_ARGUMENT); response = Ok(responseContent); } return(response); }