Stamplay / stamplay-js-sdk

:rocket: JavaScript SDK of Stamplay cloud platform
https://stamplay.com
MIT License
88 stars 18 forks source link

Logout if the hosting is not provided from Stamplay #20

Closed mirkods closed 8 years ago

mirkods commented 8 years ago

If there is an app that use Stamplay only as backend without the hosting the logout method redirect the user on a link with this format:

In this case because the host is not provided by Stamplay this means that this endpoint should be implemented on the customer's webserver.

mirkods commented 8 years ago

Solved with version 2.0.3!

samarthagarwal commented 8 years ago

I could not get it to work. The user is still redirected to http[s]://customdomain.com/auth/v1/logout. Let me know if I need to do something else.

criroselli commented 8 years ago

@samarthagarwal Do you want an asyncronous logout ?

samarthagarwal commented 8 years ago

That would be good. But as of now I don't have a route at /auth/v1/logout in my application. So as soon as I (or a user) tries to logout, they get a 404. What are the possible solutions?

PS: It would be great if we could provide a url to redirect to after logout.

criroselli commented 8 years ago

Inizialize the sdk with absoluteUrl option:

Stamplay.init('APPID', { absoluteUrl: true })

samarthagarwal commented 8 years ago

I just tried that. Still the same problem.

criroselli commented 8 years ago

Which version of the sdk are you using ?

samarthagarwal commented 8 years ago

The latest one, 2.0.3. I just updated.

criroselli commented 8 years ago

Mmmh it's so strange! Can you give me more information about it?

This is the line of code that manage the redirection https://github.com/Stamplay/stamplay-js-sdk/blob/master/src/user.js#L79

samarthagarwal commented 8 years ago

Can you give me a code example of how to call the logout method asynchronously? I think that something is causing async to be false.

criroselli commented 8 years ago

Stamplay.User.logout(true, [callback])

samarthagarwal commented 8 years ago

Yes, I am doing the same. I see an error in GET request for /auth/v1/logout and then an immediate redirect to my homepage happens. Half a second later I see this. screenshot_2

criroselli commented 8 years ago

What kind of error ? If you want you can write to me in the Stamplay Slack community or via email

samarthagarwal commented 8 years ago

Update: I removed everything from the callback and just placed a console.log("From Logout Callback"). Here is the error screenshot.

screenshot_4

samarthagarwal commented 8 years ago

Kind of working fine for me now. Just getting the error above. Thanks.

criroselli commented 8 years ago

Is not an issue on the sdk, please add the custom domain in the cors on editor.stamplay.com schermata 2016-03-14 alle 15 18 33

samarthagarwal commented 8 years ago

The error shows the URL from the Stamplay, not my custom domain. Also the custom domain is already added.

screenshot_5