Ejemplo n.º 1
0
        public void Process(DoLoginPipelineArgs args)
        {
            if (args?.User != null)
            {
                if (string.IsNullOrWhiteSpace(args.User.Profile.Email))
                {
                    args.User.Profile.Email = args.PrincipalClaimsInformation.Email;
                }

                if (string.IsNullOrWhiteSpace(args.User.Profile.Name))
                {
                    args.User.Profile.Name = args.PrincipalClaimsInformation.DisplayName;
                }

                if (string.IsNullOrEmpty(args.User.Profile.FullName))
                {
                    args.User.Profile.FullName = args.PrincipalClaimsInformation.DisplayName;
                }

                args.User.Profile.Save();

                // force a refresh of the user profile cache for the user
                CacheManager.GetUserProfileCache()
                .RemoveUser(args.User.Name);
            }
        }
        public void Process(DoLoginPipelineArgs args)
        {
            LoginSiteInfo currentSiteInfo = new LoginSiteInfo(Sitecore.Context.Site.SiteInfo);

            if (args != null && args.Principal == null)
            {
                args.Principal = _identityHelper.GetCurrentClaimsPrincipal();
            }

            // NOTE [ILs] OAuth Principal is hidden during login so try fetching it
            if (args != null && args.Principal == null)
            {
                ClaimsIdentity identity = args.HttpContext.GetOwinContext().Get <ClaimsIdentity>(OAuthAuthentication.OAuthOwinContextKey);
                if (identity != null)
                {
                    args.Principal = new ClaimsPrincipal(identity);
                }
            }

            if (args?.Principal != null && args.PrincipalClaimsInformation == null)
            {
                ClaimsPrincipal principal = args.Principal as ClaimsPrincipal;

                Type principalClaimsInformationType = Type.GetType(currentSiteInfo.PrincipleClaimsInfoClass);
                if (principalClaimsInformationType != null)
                {
                    args.PrincipalClaimsInformation =
                        (IPrincipalClaimsInformation)
                        Activator.CreateInstance(principalClaimsInformationType, principal?.Claims);
                }
            }
        }
Ejemplo n.º 3
0
 public void Process(DoLoginPipelineArgs args)
 {
     if (args != null && args.PostLoginAction == null)
     {
         args.PostLoginAction = new RedirectResult(GetRedirectUrl(args.ReturnUrlQueryString).ToString());
     }
 }
Ejemplo n.º 4
0
        public void Process(DoLoginPipelineArgs args)
        {
            LoginSiteInfo currentSiteInfo = new LoginSiteInfo(Sitecore.Context.Site.SiteInfo);

            if (args?.ValidRoles.Count == 0)
            {
                args.ValidRoles.AddRange(currentSiteInfo.ValidRoles);
            }
        }
Ejemplo n.º 5
0
        public void Process(DoLoginPipelineArgs args)
        {
            if (args?.Principal?.Identity != null && _currentTracker?.Session != null && !string.IsNullOrWhiteSpace(args.PrincipalClaimsInformation?.Email))
            {
                Session session = _currentTracker.Session;
                session.Identify(args.PrincipalClaimsInformation.Email);

                SetPersonalInfo(session, args.PrincipalClaimsInformation);
                SetEmail(session, args.PrincipalClaimsInformation.Email);
            }
        }
 public void Process(DoLoginPipelineArgs args)
 {
     if (args?.User == null &&
         args?.Principal != null &&
         args.Principal.Identity.IsAuthenticated)
     {
         ClaimsPrincipal principal = args.Principal as ClaimsPrincipal;
         if (principal != null &&
             (!args.ValidRoles.Any() || args.PrincipalClaimsInformation.Roles.Intersect(args.ValidRoles).Any()))
         {
             string accountName = args.PrincipalClaimsInformation.AccountName;
             string userName    = $"{Context.Domain.Name}\\{accountName}";
             User   virtualUser = AuthenticationManager.BuildVirtualUser(userName, true);
             AuthenticationManager.Login(virtualUser);
             args.User = virtualUser;
         }
     }
 }