public async Task <ActionResult> Login(UserModel model, string returnUrl) { if (ModelState.IsValid) { bool isLoggedIn = false; using (TableauAuthenticator authenticator = new TableauAuthenticator()) { try { isLoggedIn = await authenticator.AuthenticateAsync(model.UserName, model.Password); } catch (Exception) { } } if (isLoggedIn) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); return(RedirectToLocal(returnUrl)); } else { ModelState.AddModelError("", "Incorrect user name or password."); } } // If we got this far, something failed ViewBag.Title = "Login"; return(View(model)); }
public async Task <ActionResult> GetTrustedURL() { var ticket = string.Empty; TableauAuthenticator ta = null; try { ta = new TableauAuthenticator(); ticket = await ta.GetTicket(User.Identity.Name); } catch (Exception ex) { Console.WriteLine("Tablau Ticket Error - " + ex.Message); Console.WriteLine(ex.StackTrace); } finally { ta.Dispose(); } var trustedUrl = ConfigurationManager.AppSettings["tableauServerAddress"] + "/trusted/" + ticket; var data = new { trustedUrl = trustedUrl }; return(Json(data)); }