Frage

I started integrating SecureSocial in my play/scala app, but I don't really like all the redirects it does between it's different views.

example - try to login from it's default login page and if you put in a wrong pass you will be redirected to a different page (url) but with the same login form. the only thing that is different is that there is an error message...

I want a simple login form (user/password provider) at the corner of my main page that submits it's data using ajax, this data is validated on the server and a response is made to either display error message/s or change the window.location. Next to this form I will put a link to go to a more advanced login page that adds the option to use other providers like fb/twitter etc.. But from that page I also want to use ajax to submit the details and get the response.

I tried to browse into the SecureSocial source but got a little lost in there.

Can any one give me an idea how to use SecureSocial's but without using any of it's views?

NOTE: I'm not interested in customizing their views, It's not just a CSS/design issue, I want to handle the login details Ajaxly and not with normal form submission followed by redirects...

War es hilfreich?

Lösung

After some more rummaging around in SecureSocial code I got a better understanding of how it operates.

You can use any of the providers you listed in the play.plugins file seperatly to authenthicate the user's info from your own login/auth code. just make sure you send the right parameters that the provider needs.

I liked the way SecureSocial's ProviderController class dynamically decided what provider to use, based on a parameter. But I didn't like the responses it made - redirect.. I wanted to respond to an ajax request with some data and let the client side js handle it.

This is my solution:

pretty much copy all of ProviderController code to my own Auth.scala file (a Controller). Changed the redirects related to "case ex, case _", kept the redirect on successful auth as it adds the SecureSocial session key related to the user. Removed all the SecureSocial related routes from my routes file. Put an additional hidden field with the logintype (userpass/google/fb/etc...) and configured my login ajax post to sent this along with the post to my Auth controller.

If you need more info comment here and I'll edit the answer.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top