We have a case where we need to notify approvers when a page is sent for approval.
In the notification email, I want to include a link so that the approvers can go directly to the page in the Sitecore Experience Editor (version 8.1-Update 1). If they are not logged in, they should naturally get the login form and then be redirect the the requested page.
We have done something similar before with the Content Editor using a URL on the format:
{cmsHost}/sitecore/shell/Applications/Content%20Editor.aspx?id={itemID}&fo={itemID}&la={itemLanguage}
If the user is not logged in, they are redirected to /sitecore/login with a returnUrl parameter that points to my link. After logging in, the user is automatically redirected to the correct page in the Content Editor.
For the Experience Editor, I tried to use the URL format:
{cmsHost}/?sc_itemid={itemID}&sc_lang={itemLanguage}&sc_version={itemVersion}&sc_mode={mode}
This works fine when the user is logged in, but when the user is not logged in, the request is simply redirected to /sitecore/login without the returnUrl parameter.
After some digging it looks like the returnUrl is added specifically in the Content Editor code (and a few other applications), but there is no such logic in the Experience Editor.
I did find a configuration setting called Authentication.SaveRawUrl
that felt promising:
Specifies whether the original request URL is passed to the login page (saved in 'url' query string parameter).
Setting this to true
did indeed add a url parameter when Sitecore redirects the user to the login page. However, there are a few issues:
- There is no built-in support for actually redirecting the user after logging in (like for the returnUrl parameter).
- Linking to the Content Editor will redirect to the login form with both the returnUrl and the url parameters.
- The url is also encoded twice for some reason (I'm guessing this is a bug?).
I can see a few different possible work-arounds, but non is very appealing:
- Write another processor for redirecting after login (using the url parameter)
- Patching or rewriting the
SaveRawUrl
functionality to set the returnUrl - Linking to a custom handler that checks if the user is logged in and redirects accordingly
Quite frankly this feels like a fairly standard feature that should work uniformly out-of-the-box?
Is there a preferred way of doing this sort of external deep links to the Experience Editor?