Exemplo n.º 1
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;
        }
Exemplo n.º 2
0
 public SocialPrincipal(SocialIdentity identity, IDataService dataService)
 {
     _identity    = identity;
     _dataService = dataService;
 }