public void OnAuthorization(AuthorizationContext filterContext)
        {
            IIdentity identity = filterContext.HttpContext.User.Identity;

            HttpCookie formsCookie = filterContext.HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName];
            SocialIdentity newIdentity = formsCookie != null
                                             ? new SocialIdentity(identity.Name,
                                                                  FormsAuthentication.Decrypt(formsCookie.Value))
                                             : new SocialIdentity(identity.Name, null);

            var dataService = DependencyResolver.Current.GetService(typeof(IDataService)) as IDataService;

            var principal = new SocialPrincipal(newIdentity, dataService);

            filterContext.HttpContext.User = principal;
            Thread.CurrentPrincipal = principal;
        }
Exemple #2
0
        public void OnAuthorization(AuthorizationContext filterContext)
        {
            IIdentity identity = filterContext.HttpContext.User.Identity;

            HttpCookie     formsCookie = filterContext.HttpContext.Request.Cookies[FormsAuthentication.FormsCookieName];
            SocialIdentity newIdentity = formsCookie != null
                                             ? new SocialIdentity(identity.Name,
                                                                  FormsAuthentication.Decrypt(formsCookie.Value))
                                             : new SocialIdentity(identity.Name, null);

            var dataService = DependencyResolver.Current.GetService(typeof(IDataService)) as IDataService;

            var principal = new SocialPrincipal(newIdentity, dataService);

            filterContext.HttpContext.User = principal;
            Thread.CurrentPrincipal        = principal;
        }