public ActionResult Check2(LoginWithTenantDetailModel t, String preView) { var auth = CheckWebService(t); if (auth.AuthToken == null) { Session["validateLogin"] = false; ModelState.AddModelError("", ""); return View("UserSignIn"); } if (preView == "UserSignIn") { preView = "Methods"; } return RedirectToAction("Methods", new {TenantKey = Server.UrlEncode(auth.TenantKey), AuthToken = Server.UrlEncode(auth.AuthToken)}); }
private AuthenticationModel CheckWebService(LoginWithTenantDetailModel l) { l.TenantDetail = (TenantDetailModel) Session["tenantKey"]; AuthenticationModel authenticationModel = new AuthenticationModel(); string url = "api/v1.0/Authentication/Login"; HttpClient client = new HttpClient(); client.BaseAddress = new Uri("https://api.connectedcommunity.org/"); authenticationModel.TenantKey = l.TenantDetail.TenantKey; // Add an Accept header for JSON format. client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Add("HLTenantKey", authenticationModel.TenantKey); // List all products. HttpResponseMessage response = client.PostAsJsonAsync(url, l.Login).Result; // Blocking call! if (response.IsSuccessStatusCode) { authenticationModel.AuthToken = ((string[])(response.Headers.GetValues("HLAuthToken")))[0]; } return authenticationModel; }
public ActionResult UserSignIn(LoginWithTenantDetailModel l) { Session.Add("validateLogin", true); return View(); }