My site is an authenticated website, and we have incorporated some authorization that will only allow certain people to see certain pages. Its all a proprietary setup, something that was in place before we started making the switch to Umbraco. But my problem is my editors can not view a page in preview mode without logging in to the site. Is there a way to detect I am in preview? I've tried the following but none worked:
if (Session["UmbracoLiveEditingMode"] != null && bool.Parse(Session["UmbracoLiveEditingMode"].ToString()))
if (umbraco.GlobalSettings.RequestIsInUmbracoApplication(HttpContext.Current) && umbraco.presentation.UmbracoContext.Current.LiveEditingContext.Enabled)
Never seems to fail. I look around for hours. I post a question here. Then immediatly I find what I'm looking for. Maybe I should just start asking first :)
The answer seems to be:
if (umbraco.presentation.UmbracoContext.Current.InPreviewMode)
FYI, you can also check for the existence of the "UMB_PREVIEW" cookie - probably more useful if you need to check from XSLT or somewhere other than .NET though.
This is all working fine and I am using the cookie in my XSLT...but then i ran into a snag. My website is an authenticated user website. There are some pieces of information we dont want unauthenticated users to see and we lock down our pages accordingly. I dont want my editors to have to be authenticated to see their pages in preview mode, hence this topic. But at the same time, its super easy to inject a cookie into my browser and someone with any knowledge of umbraco could do so, and see basically everything without logging in. So are there some alternatives?
How can I tell if I'm in preview mode?
My site is an authenticated website, and we have incorporated some authorization that will only allow certain people to see certain pages. Its all a proprietary setup, something that was in place before we started making the switch to Umbraco. But my problem is my editors can not view a page in preview mode without logging in to the site. Is there a way to detect I am in preview? I've tried the following but none worked:
if (Session["UmbracoLiveEditingMode"] != null && bool.Parse(Session["UmbracoLiveEditingMode"].ToString()))
if (umbraco.GlobalSettings.RequestIsInUmbracoApplication(HttpContext.Current) && umbraco.presentation.UmbracoContext.Current.LiveEditingContext.Enabled)
if (Page is umbraco.BasePages.BasePage)
I'm running 4.7.1.
Never seems to fail. I look around for hours. I post a question here. Then immediatly I find what I'm looking for. Maybe I should just start asking first :)
The answer seems to be:
if (umbraco.presentation.UmbracoContext.Current.InPreviewMode)
FYI, you can also check for the existence of the "UMB_PREVIEW" cookie - probably more useful if you need to check from XSLT or somewhere other than .NET though.
This is all working fine and I am using the cookie in my XSLT...but then i ran into a snag. My website is an authenticated user website. There are some pieces of information we dont want unauthenticated users to see and we lock down our pages accordingly. I dont want my editors to have to be authenticated to see their pages in preview mode, hence this topic. But at the same time, its super easy to inject a cookie into my browser and someone with any knowledge of umbraco could do so, and see basically everything without logging in. So are there some alternatives?
is working on a reply...