public async Task<ActionResult> AuthenticateFromCode(string code) { if (Request.Headers.Get("host").Contains("localhost")) { SessionWrapper.Clear(); var refreshTokenCookie = Response.Cookies["refresh_token"]; var accessTokenCookie = Response.Cookies["access_token"]; if (refreshTokenCookie != null && !string.IsNullOrEmpty(refreshTokenCookie.Value)) { refreshTokenCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(refreshTokenCookie); } if (accessTokenCookie != null && !string.IsNullOrEmpty(accessTokenCookie.Value)) { accessTokenCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(accessTokenCookie); } return Redirect("/home"); } var user = await TryAuthenticateFromAuthCode(code); _baseModel.User = user; string url = Uri.UnescapeDataString(Request.QueryString["returnUrl"]).ToLower(); if (url.IndexOf("/community") != -1) { return Redirect("/Community"); } if (url.IndexOf("/webclient") != -1) { return Redirect("/webclient?loggedIn=true"); } return Redirect("/home"); }
public async Task<JsonResult> Authenticate() { var profile = await TryAuthenticateFromHttpContext(); if (profile != null) { _baseModel.User = profile; return Json(new { Status = "Connected", Session = new { User = SessionWrapper.Get<string>("CurrentUserProfileName") }, }, JsonRequestBehavior.AllowGet); } var svc = new LiveIdAuth(); var url = svc.GetLogoutUrl("http://" + Request.Headers.Get("host")); SessionWrapper.Clear(); return Json(new { Status = "unknown", S = url }, JsonRequestBehavior.AllowGet); }
public async Task <JsonResult> Authenticate() { var result = await TryAuthenticateFromHttpContext(_communityService, _notificationService); if (result.Status == LiveConnectSessionStatus.Connected) { _baseModel.User = SessionWrapper.Get <ProfileDetails>("ProfileDetails"); return(Json(new { Status = result.Status.ToString(), Session = new { result.Session.AccessToken, result.Session.AuthenticationToken, Expires = result.Session.Expires.ToLocalTime().ToString(), result.Session.RefreshToken, result.Session.Scopes, User = SessionWrapper.Get <string>("CurrentUserProfileName") }, }, JsonRequestBehavior.AllowGet)); } var svc = new LiveIdAuth(); var url = svc.GetLogoutUrl("http://" + Request.Headers.Get("host")); SessionWrapper.Clear(); return(Json(new { Status = result.Status.ToString(), S = url }, JsonRequestBehavior.AllowGet)); }
public ActionResult Logout() { var svc = SessionWrapper.Get <LiveIdAuth>("LiveAuthSvc"); var url = "/"; if (svc != null) { url = svc.GetLogoutUrl("http://" + Request.Headers.Get("host")); } SessionWrapper.Clear(); return(Redirect(url)); //View("~/Views/Index.cshtml", baseModel); }
public ActionResult Logout() { var svc = new LiveIdAuth(); var url = svc.GetLogoutUrl("http://" + Request.Headers.Get("host")); SessionWrapper.Clear(); var refreshTokenCookie = Response.Cookies["refresh_token"]; var accessTokenCookie = Response.Cookies["access_token"]; if (refreshTokenCookie != null && !string.IsNullOrEmpty(refreshTokenCookie.Value)) { refreshTokenCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(refreshTokenCookie); } if (accessTokenCookie != null && !string.IsNullOrEmpty(accessTokenCookie.Value)) { accessTokenCookie.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(accessTokenCookie); } return Redirect(url); }