public async Task <ResponseData <ValidateUserResult> > ValidateUserNameAndPassword( [FromBody] ValidateUserNameAndPasswordInput validateUserNameAndPasswordInput) { try { if (User.Identity.IsAuthenticated) { if (User.Claims.Single(r => r.Type == "role").Value == Startup.Configuration.GetSection("AccessLevel").GetSection("AccessLevel1").Value) { if (ModelState.IsValid) { return(await manageUserRepository.ValidateUserNameAndPassword( validateUserNameAndPasswordInput.userName, validateUserNameAndPasswordInput.userPasswordHash)); } else { return(new ResponseData <ValidateUserResult>() { responseCode = (int)ResponseStatusEnum.BadRequest, responseStatusDescription = "Bad Request", responseResults = null }); } } else { return(new ResponseData <ValidateUserResult>() { responseCode = (int)ResponseStatusEnum.AuthorizationFail, responseStatusDescription = "Authorization Fail", responseResults = null }); } } else { return(new ResponseData <ValidateUserResult>() { responseCode = (int)ResponseStatusEnum.AuthenticationFail, responseStatusDescription = "Authentication Fail", responseResults = null }); } } catch (Exception ex) { Console.WriteLine(ex.Message.ToString()); return(new ResponseData <ValidateUserResult>() { responseCode = (int)ResponseStatusEnum.APIError, responseStatusDescription = "API Error", responseResults = null }); } }
public async Task GetsFundNamesPassingTest() { ValidateUserNameAndPasswordInput validateUserNameAndPasswordInput = new ValidateUserNameAndPasswordInput() { userName = "******", userPasswordHash = "bb96c2fc40d2d54617d6f276febe571f623a8dadf0b734855299b0e107fda32cf6b69f2da32b36445d73690b93cbd0f7bfc20e0f7f28553d2a4428f23b716e90" }; string validateUserNameAndPasswordInputJsonString = JsonConvert.SerializeObject( validateUserNameAndPasswordInput); HttpResponseMessage httpResponse = await ConnectHelper.HttpPostHelper(httpClient, validateUserNameAndPasswordInputJsonString, "ManageUser/ValidateUserNameAndPassword"); Assert.Equal(httpResponse.StatusCode, HttpStatusCode.OK); var httpResponseContent = JObject.Parse(await httpResponse.Content.ReadAsStringAsync()); Assert.Equal(Convert.ToInt32(httpResponseContent.GetValue("responseCode").ToString()), (int)ResponseStatusEnum.Success); }