我在我的网站上实施了一个简单的注册流程 - 用户以注册形式输入电子邮件,系统通过一些随机哈希发送该电子邮件确认链接以完成结账。链接看起来像这样:
http://somedomain.com/registration_confirm/1/be770f0a002f181deedcb3d8da2f9f638579ace3fe218251fe3558824ba548d2
另外,在电子邮件模板中:
<a href="{{ url('registration_confirm', { '_locale': app.request.locale, 'readerId': readerId, 'registrationDigest': registrationDigest }) }}">
{{ 'registration.link'|trans({}, "emails") }}
</a>
当它在 Gmail 上传递时,我点击了该链接 - 发生了一些奇怪的事情:目标页面被加载了两次。所以我进入registration_confirm
路由,然后浏览器再次加载registration_confirm
路由。哪个是问题,因为第二个加载链接不再有效,并且用户看到错误。
Symfony2 是框架,我的路由定义如下:
/**
* @Method({"GET"})
* @Route(
* "/registration_confirm/{readerId}/{registrationDigest}",
* name="registration_confirm",
* host="{domain}",
* defaults={"_locale" = "%locale%", "domain" = "%domain%"},
* requirements={"_locale" = "%locale%", "domain" = "%domain%", "readerId" = "\d+", "registrationDigest" = "[a-f0-9]{64}"}
* )
*/
跨不同浏览器检查 - 结果相同。使用不同的电子邮件服务进行检查 - 除Gmail之外的其他所有服务都按预期工作,因此我认为Gmail本身会执行不需要的操作。
欣赏有关此问题的任何想法,因为现在它看起来像伏都教魔法。