Beispiel #1
0
        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);
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
 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); 
 }