春季安全打开一个弹出登录 [英] Spring security opening a popup login

查看:109
本文介绍了春季安全打开一个弹出登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何打开一个弹出登录(以Spring Security),当用户做一些事情,需要进行身份验证来验证和他不是。

Someone knows how to open a popup login to authenticate (using spring security) when the user does something that needs to be authenticated and he is not.

例如:让我们想象中的页面有一个按钮立即购买,该产品添加到购物车,进行结帐(现在购买页),如果用户已经通过身份验证,或者打开一个弹出对用户进行的身份认证。

For example: Lets imagine the page has one button "buy now" that add the product to the cart and perform the checkout (buy now page), if the user is already authenticated, or, opens a popup for the user perform the authentication.

如果验证成功比弹簧重定向到立即购买页面或在打开弹出窗口,页面停留(有错误信息错误的登录)。

If the authentication is successful than the spring redirects to the "buy now" page or stays in that page with the popup opened (with an error message "wrong login").

我已经在谷歌搜索的一种解决方案,但没有运气。

I already searched in google for a kind of solution but without luck.

有人能指出我朝着正确的方向吗?

Someone can point me in the right direction?

感谢

推荐答案

只是一个想法,还没有来得及对其进行测试。这只是客户端。

Just an idea, haven't had time to test it. It's client-side only.


  1. 把一个事件监听链接/按钮,点击事件

  2. 使用Javascript和调用通过 XMLHtt prequest 表单操作或链接

  3. 检查HTTP状态code: xhr.status

  4. 如果(OK)替换目标URL(的通过Htm​​l5的历史API ​​),并替换 xhr.responseText (什么通过W3C DOM 更换整个HTML文档)其他选项

  5. 否则,如果(重定向)只要按照重定向

  6. 否则,如果(未授权)打开弹出

  1. Put an Eventlistener on the Link/Button-Click-Event
  2. Use Javascript and call the form-action or link via XMLHttpRequest
  3. Check the HTTP status code: xhr.status
  4. if (OK) replace the current url with the target url (via Html5 History API) and replace the entire document with xhr.responseText (What other options for replacing entire HTML document via W3C DOM)
  5. else if (Redirect) just follow the redirect
  6. else if (Unauthorized) open popup

这篇关于春季安全打开一个弹出登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆