The flow for my application, for non-logined users, looks like this:
1) non-logined user does a given action that requires login (arbitrary)
2) dialog appears for non-logined user and he logins without any refreshing of the page
3) collecting of additional information if it is new user
3) the given action should be executed
How can i do so? I believe it can be done with carefully structured callbacks. Part of the tricky part is that there are a range of potential actions
Store the action as a callback in a variable:
When a non-logged user attempts to execute this action, by clicking a button, or whatever, your application should pass the callback as an argument to the log-in function like this:
… where
callbackis what will be executed on a succesful login. Putting it all together:Just be sure you do some kind of server side validation, as my example is simplistic and easily hacked.