ruby-on-rails - 密码重置令牌泄露给谷歌分析
问题描述
当用户单击电子邮件中的链接以重置令牌时,我的重置密码令牌泄漏给谷歌分析。 http://localhost:5000/users/password/edit?reset_password_token=g1xMHpjsDEE3MkMFUapo
检查后我可以看到
尝试了以下链接,但没有用,请帮助。
https://thoughtbot.com/blog/is-your-site-leaking-password-reset-links
https://github.com/thoughtbot/clearance/pull/707
https://github.com/thoughtbot/clearance/pull/706
我的 passwords_controller.rb
def create self.resource = resource_class.send_reset_password_instructions(resource_params) 如果 block_given 产生资源?
if successfully_sent?(resource)
respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
else
respond_with(resource)
end
结尾
def edit self.resource = resource_class.new resource.reset_password_token = params[:reset_password_token] end
解决方案
您可以从该特定页面中删除 Google Analytics 脚本。
我假设您在应用程序布局文件中导入脚本,因此您有两个选择:
- 为用户模型创建一个单独的布局文件。
- 在当前布局文件中放置一个条件以检查控制器,如果它正在重置用户密码,则不导入谷歌分析。
如果你做两者之一,它应该停止“泄漏”。
推荐阅读
- java - 属性 [path] 对于标签错误是必需的,但指定了路径
- mongodb - 在聚合 MongoDB 中使用计数
- php - Laravel 跨域共享会话
- cmake - 带有 Emscripten 和 vcpkg 的 CMake 无法绑定两个 TOOLCHAIN_FILES
- google-cloud-firestore - 使用 Zapier 获取 FireStore 子集合 ID
- composer-php - Laravel 7 无法安装 laravel voyager
- javascript - jQuery箭头函数替代
- python - 如何在 Django 模板中使用 Bootstrap/静态文件
- javascript - 在对象数组中按特定键计算分组值
- python - 如何根据python中的条件提取文本