Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring security opening a popup login

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?

Thanks

like image 370
amachado Avatar asked Nov 01 '22 17:11

amachado


1 Answers

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

  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
like image 167
Paul Henke Avatar answered Nov 15 '22 05:11

Paul Henke