在 Sitecore 客户端中链接到项目的优雅方式?
我正在寻找链接到 Sitecore 客户端(不是外部网站)中的项目的最佳方式。该链接将嵌入到损坏的链接报告电子邮件中。用户应该能够单击链接并启动 Sitecore 内容编辑器,并在树中自动选择该项目。
我在 Mark Ursino 的博客这里找到了他的解决方案,但不幸的是,它只有在您主动登录 Sitecore 时才有效(否则,登录后它会将您带到 Sitecore 桌面)。
我正在运行 Sitecore.NET 6.4.1(修订版 110324)
更新
只是为了关闭 Marko 解决方案的循环:
public void Process(LoggedInArgs args)
{
string url = HttpUtility.UrlDecode(WebUtil.GetQueryString("url"));
// Ensure we're dealing with the client login site and there is a URL to redirect to
if (Sitecore.Context.GetSiteName() == "login" &&
!String.IsNullOrEmpty(url))
{
var queryString = WebUtil.ParseQueryString(url);
// Check for redirect param to prevent accidental redirections
if (queryString.ContainsKey("redirectAfterLogin"))
WebUtil.Redirect(url);
}
}
I am looking for the best way to link to an item in the Sitecore client (not the external website). The link will be embedded in a broken links report email. The user should be able to click the link and launch the Sitecore content editor with that Item auto-selected in the tree.
I have found Mark Ursino's solution on his blog here, but unfortunately, it only works if you are actively logged into Sitecore (Otherwise, it brings you to the Sitecore Desktop after logging in).
I am running Sitecore.NET 6.4.1 (rev. 110324)
UPDATE
Just to close the loop on Marko's solution:
public void Process(LoggedInArgs args)
{
string url = HttpUtility.UrlDecode(WebUtil.GetQueryString("url"));
// Ensure we're dealing with the client login site and there is a URL to redirect to
if (Sitecore.Context.GetSiteName() == "login" &&
!String.IsNullOrEmpty(url))
{
var queryString = WebUtil.ParseQueryString(url);
// Check for redirect param to prevent accidental redirections
if (queryString.ContainsKey("redirectAfterLogin"))
WebUtil.Redirect(url);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
发布评论
评论(3)
这是我之前使用过的:
sitecore web.config 中有一个选项可以通过原始网址发送。 然后,我在 CleanupUserProfile 之后向登录
<setting name="Authentication.SaveRawUrl">
<patch:attribute name="value">true</patch:attribute>
</setting>
处理器中添加了一个额外的处理器,该处理器读取查询字符串参数并重定向到适当的页面。无论用户之前是否登录过,都会调用该处理器。
我的自定义登录处理器的签名是
namespace [...]
{
public class LoginModeSwitcher
{
public void Process(LoggedInArgs args)
{
// your code here
}
}
}
这是我用于登录处理器的补丁配置:
<processors>
<loggedin>
<processor patch:after="*[@type='Sitecore.Pipelines.LoggedIn.CleanupUserProfile, Sitecore.Kernel']" mode="on" type="[...].LoginModeSwitcher, [ASSEMBLY]" />
</loggedin>
</processors>
电子邮件链接中的链接包含一个查询字符串参数,告诉我的代码我们要在登录后重定向,并将其他查询字符串参数重定向到告诉它将用户重定向到哪里。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
您希望有一个页面,所有链接都指向登录过程,然后重定向到 Sitecore。您需要将一些查询字符串参数添加到电子邮件中链接的 URL,例如:itemID 和serialCode。由于执行此类操作的安全隐患,我强烈建议您设置一个加密代码,该代码可以在可以解密的链接中发送,并根据该特定报告的存储代码进行检查,以确保尝试登录的人是您将电子邮件发送给的人。检查代码后,您将访问低级用户凭据,您可以将其存储在 web.config 中以自动登录。然后,您可以使用 itemID 来确定要在内容编辑器中打开哪个项目。 (请注意,避开 Sitecore 的登录过程会打开安全漏洞,您应该做好防御准备)
另一个不太复杂且更安全的选择是通过电子邮件发送新报告的摘要和通知,并附有指向 Sitecore 登录页面的链接。然后在 Sitecore 中创建一个自定义应用程序来创建和查看这些报告。然后,电子邮件的预期收件人可以登录并使用此应用程序在收到通知后查看电子邮件。这与日志查看器的工作方式类似。一旦进入 Sitecore 的桌面模式,他们就可以在内容编辑器和自定义应用程序之间切换,然后自定义应用程序可以包含指向所有项目的链接列表。这当然取决于客户的灵活性。
You'd want to have a single page that all you're links point to which process the login and then redirect to Sitecore. You'd want to add a few querystring parameters to the url of the links in the email such as: itemID and serialCode. I highly recommend, because of the security implications of doing this type of thing, that you setup an encrypted code that can be sent in the links that can be unencrypted and checked against a stored code for that particular report to ensure the person trying to login is who you sent the email to. After checking the code you would access the low level user credentials which you could store in your web.config to login automatically. Then you'd use the itemID to determine which item to open in the content editor. (Note that sidestepping Sitecore's login process will open security holes you should be prepared to defend against)
Another less complicated and more secure option would be to email a summary and notification of the new report with a link to the Sitecore login page. Then create a custom application within Sitecore to create and view these reports. The email's intended recipient can then login and use this application to view it when they've been notified. It would be similar to how the log viewer works. Once inside Sitecore's desktop mode they could flip between the content editor and your custom application which could then have a list of links to all the items. This of course depends on the flexibility of your client.