Shazwazza / UmbracoIdentity

ASP.NET Identity implementation for Umbraco's native member data
MIT License
111 stars 58 forks source link

Question - Umbraco Content within ExternalLoginFailure #143

Open OwainWilliams opened 3 years ago

OwainWilliams commented 3 years ago

Hi Shannon,

We’ve got the UmbracoIdentity package installed and we are looking to style the ExternalLoginFailure view. However, we can’t figure out how to get the current site reference into the request pipeline. Ideally, we would like to be able to use the master template that the site uses and have the same navigation driven by Umbraco Content, but when we try to get the Umbraco root node of the site our rendering breaks with the following error: Cannot return the IPublishedContent because the UmbracoHelper was not constructed with an IPublishedContent..

The ExternalLoginFailure view is called from the ExteralLoginCallback method and from the ExternalLoginFailure method. The Latter of which we are using as a test call and have modified it as follows:

public ActionResult ExternalLoginFailure(string returnUrl = null)
        {
            IPublishedContent node = UmbracoContext.Content.GetByRoute(returnUrl.IfNullOrWhiteSpace("/"));
            if(node != null)
            {
                var siteRoot = node.Root();
                var loginFailureDetails = siteRoot.FirstChildOfType(LoginFailure.ModelTypeAlias);
                if (loginFailureDetails != null)
                    node = loginFailureDetails;
            }

            return View("ExternalLoginFailure", node);
        }

Fundamentally, the question we have is:

How can we incorporate our site properly into the views returned back from this controller to ensure we have consistent branding etc without having to duplicate lost of html/render code?

Thanks

OwainWilliams commented 3 years ago

Hi @Shazwazza - Just wondered if you had any thoughts on this at all? Thanks!