如何删除“确认表单重新提交”坦克授权
您好,我一直在 CI 中使用 Tank auth,我认为它很棒,我只是想知道是否有办法更改它,以便当用户刷新登录页面(登录错误后)时,“确认表单重新提交”弹出窗口不会出现出现。我一直在阅读帖子重定向获取方法,但我不想搞乱坦克身份验证。 PS-我很菜鸟
Hi I have been using tank auth for CI and I think it's awesome, I was just wondering if there was a way to change it so when a user refreshes the login page (after login errors), the 'confirm form resubmission' popup does not show up. I have been reading up on the post redirect get method but I dont wanna mess up tank auth. ps - im pretty noobish
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此“确认表单重新提交”来自您的网络浏览器,而不是来自 Tank Auth。
不久前,有人编写网络浏览器时意识到重新发布是一个大问题,因此他们发出警告以停止 ppl 双重发布等。
我可以想出两种方法来避免它。
1) 将登录“post”改为“get”。
这是一个坏主意。因为您的密码位于查询字符串中
2) 在登录失败时,在身份验证控制器中重定向到登录表单的错误显示版本,而不是再次加载登录表单视图。
基本上,您找到了一种通过查询字符串或会话将错误消息传递到登录表单的方法。重定向到该页面。这非常简单,因为 Tank auth 使用语言键来处理错误。
我只是尝试将它作为查询字符串..似乎工作正常,但我的坦克身份验证经过了相当大的修改。
我将其添加到
controllers/auth.php
中的//fail
部分之后,这将获取由 Tank auth 生成的登录错误密钥并将其传递回
http://yoursite/auth/login
作为查询参数。然后在登录函数的顶部我放置了这样的内容:
此代码将获取参数(如果存在)。然后从语言文件中获取相应的行,然后加载登录表单。
请注意,这只会处理“登录”错误。您将需要传递更多查询参数来处理验证错误等问题。
// 编辑
我想我应该尝试会话方式......而且它更简洁。
这发生在
//fail
位置,类似的东西出现在views/auth/login_form.php中,而不是form_errors所在的位置。
This 'confirm form resubmission' is from your web browser, not from Tank Auth.
Some time ago someone coding a web browser realised that reposting is a big problem so they put in a warning to stop ppl double-posting and such.
I can think of 2 ways to avoid it.
1) Make the login 'post' into a 'get'.
This is a BAD idea. cos your password is in the query string
2) In the auth controller redirect to an error display version of the login form on login fail instead of loading the login form view again.
basically you find a way to pass the error message to your login form via query string or session. the redirect to that page. Its pretty easy since tank auth uses language keys for errors.
I just tried it as a query string.. seems to work ok, but my tank auth is pretty heavily modified.
I added this to
controllers/auth.php
right after the part where it says//fail
this takes the login error key generated by tank auth and passes it back to
http://yoursite/auth/login
as a query parameter.then at the top of the login function I put this:
this code grabs the parameter if its there.. then grabs the appropriate line from your language file, then loads the login form.
note this will only handle 'login' errors. you will need to pass more query parameters to handle things like validation errors.
// edit
I thought I'd try the session way.. and its much neater.
this goes at the
//fail
spotand something like this goes in views/auth/login_form.php instead of where the form_errors are.