コード例 #1
0
        public ActionResult LoginProviderList(string returnUrl)
        {
            var corePipelineManager = ServiceLocator.ServiceProvider.GetService <BaseCorePipelineManager>();
            //var args = new GetSignInUrlInfoArgs("website", "/");
            var args = new GetSignInUrlInfoArgs("website", string.IsNullOrEmpty(returnUrl) ?"/": returnUrl);

            GetSignInUrlInfoPipeline.Run(corePipelineManager, args);

            return(View("~/Views/Authentication/LoginProviderList.cshtml", args.Result));
        }
コード例 #2
0
        public IEnumerable <FedAuthLoginButton> GetAll()
        {
            var returnUrl = this.AccountsSettingsService.GetPageLinkOrDefault(Context.Item, Templates.AccountsSettings.Fields.AfterLoginPage);
            var args      = new GetSignInUrlInfoArgs(Context.Site.Name, returnUrl);

            GetSignInUrlInfoPipeline.Run(this.PipelineManager, args);
            if (args.Result == null)
            {
                throw new InvalidOperationException("Could not retrieve federated authentication logins");
            }
            return(args.Result.Select(CreateFedAuthLoginButton).ToArray());
        }
コード例 #3
0
        public ActionResult LeaveComment()
        {
            string[]         names = null;
            CommentViewModel model = new CommentViewModel();

            try
            {
                CommentViewModel commentModel = System.Web.HttpContext.Current.Session[Constants.CommentModel] as CommentViewModel;
                if (commentModel != null)
                {
                    model = commentModel;
                    System.Web.HttpContext.Current.Session[Constants.CommentModel] = null;
                }

                IBlog blog = _renderingRepository.GetPageContextItem <IBlog>();
                if (blog != null)
                {
                    model.parentId = blog.Id.ToString();
                }
                if (System.Web.HttpContext.Current.User != null && System.Web.HttpContext.Current.User.Identity != null && System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    string fullName = Sitecore.Context.User.Profile != null ? Sitecore.Context.User.Profile.FullName : string.Empty;
                    if (!string.IsNullOrEmpty(fullName) && !Sitecore.Context.User.IsAdministrator)
                    {
                        if (Sitecore.Context.User.Profile.Comment == Constants.GoogleLogin)
                        {
                            names = Regex.Split(fullName, @"(?<!^)(?=[A-Z])");
                        }
                        else
                        {
                            names = fullName.Split(' ');
                        }
                        model.FirstName = names.Length >= 0 ? string.IsNullOrEmpty(names[0]) ? model.FirstName : names[0] : model.FirstName;
                        model.LastName  = names.Length >= 1 ? string.IsNullOrEmpty(names[1].Trim()) ? model.LastName : names[1].Trim() : model.LastName;
                    }
                }

                if (System.Web.HttpContext.Current.User != null && System.Web.HttpContext.Current.User.Identity != null && !System.Web.HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    var corePipelineManager = DependencyResolver.Current.GetService <Sitecore.Abstractions.BaseCorePipelineManager>();
                    var args = new GetSignInUrlInfoArgs(Sitecore.Context.Site.Name, blog.Url);
                    GetSignInUrlInfoPipeline.Run(corePipelineManager, args);

                    model.signinURLInfo = args?.Result;
                }
            }
            catch (Exception ex)
            {
                Sitecore.Diagnostics.Log.Error(ex.Message, ex, this);
            }
            return(View(Constants.LeaveCommentViewName, model));
        }
コード例 #4
0
        public IEnumerable <FedAuthLoginButton> GetAll()
        {
            string returnUrl = _getRedirectUrlService.GetRedirectUrl(AuthenticationStatus.Authenticated);

            var args = new GetSignInUrlInfoArgs(Context.Site.Name, returnUrl);

            GetSignInUrlInfoPipeline.Run(_pipelineManager, args);
            if (args.Result == null)
            {
                throw new InvalidOperationException("Could not retrieve federated authentication logins");
            }

            return(args.Result.Select(CreateFedAuthLoginButton).ToArray());
        }
コード例 #5
0
        public ActionResult Index()
        {
            var url = "/";

            if (!string.IsNullOrEmpty(Request.QueryString?["item"]))
            {
                url = Request.QueryString["item"];
            }

            var codePipelineManager = DependencyResolver.Current.GetService <BaseCorePipelineManager>();
            var args = new GetSignInUrlInfoArgs("website", url);

            GetSignInUrlInfoPipeline.Run(codePipelineManager, args);

            return(View("/Views/SSO/Login.cshtml", args.Result));
        }
コード例 #6
0
        private void PerformPost()
        {
            string redirectUrl         = "/identitylogin/securedpage";
            var    corePipelineManager = ServiceLocator.ServiceProvider.GetService <BaseCorePipelineManager>();
            //var args = new GetSignInUrlInfoArgs("website", "/");
            var args = new GetSignInUrlInfoArgs("website", string.IsNullOrEmpty(redirectUrl) ? "/" : redirectUrl);

            GetSignInUrlInfoPipeline.Run(corePipelineManager, args);
            string postUrl = "https://dgaidentitysolutionqa.dga.org" + args.Result.FirstOrDefault().Href;

            WebRequest request = WebRequest.Create(postUrl);

            //Set the Method property of the request to POST.
            request.Method = "POST";

            //Get the response.
            WebResponse response = request.GetResponse();
        }
コード例 #7
0
ファイル: AuthUtility.cs プロジェクト: kmac23va/ScHelix
        public static string GetSignInUrl(string siteName, string returnUrl)
        {
            string signInUrl = string.Empty;
            BaseCorePipelineManager corePipelineManager = Sitecore.DependencyInjection.ServiceLocator.ServiceProvider.GetService <BaseCorePipelineManager>();
            GetSignInUrlInfoArgs    args = new GetSignInUrlInfoArgs(site: siteName, returnUrl: returnUrl);

            GetSignInUrlInfoPipeline.Run(corePipelineManager, args);
            Collection <SignInUrlInfo> signInCollection = args.Result;

            if (signInCollection.Count <= 0)
            {
                return(signInUrl);
            }

            SignInUrlInfo signInInfo = signInCollection[0];

            signInUrl = signInInfo.Href;

            return(signInUrl);
        }