Announcement Announcement Module
Collapse
No announcement yet.
How to best handle a 'sign in/sign up' and then 'connect' situation? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to best handle a 'sign in/sign up' and then 'connect' situation?

    I'm working on fb app that also has a stand-alone web version. The fb version will be different in a few ways and we want the user to use the application with a facebook connection.

    So far to accomplish this I started off by having the initial page load basically submit a form to: /signin/facebook

    If the user's fb account is not currently associated with the application they are brought to combination form that is similar to the showcase signup page - but rather than just have a signup form it also has a form: "Already a member? You can login with that username/password and associate this facebook account"

    When this form submits I want it to do the normal application signin stuff but then I want to call the connect/facebook code that is in the ConnectiController. The problem is the ConnectController business logic for connect/facebook code is set up as POST and I'm not sure how to call a post from spring mvc controller? (Is this possible?)

    Since I wasn't sure if it was possible I thought about just extending the ConnectController and implementing my own method that I'd define as a GET. However, there are a lot of private methods in the ConnectController that I think might be better off being protected? - pre/post Connect, processFlash etc.

    Basically when a user signs in with an existing account or if they signup for a new account I want to automatically associate this with their facebook account but I'm not sure of the best approach in order to leverage the existing ConnectController?

  • #2
    If I'm following your description correctly, I think you might be able to do what you want to do by calling ProviderSignInUtils.handlePostSignUp() just like your signup controller should do after a new user registers with your application.

    At the point when ProviderSignInController realizes that it needs to redirect to your signup page, it puts the details of the sign-in-attempt into the session. After the user signs up, your signup controller can call ProviderSignInUtils.handlePostSignUp() to complete the connection process. I would think this would also fit your case where the user decides to signin.

    Take a look at SignupController.java in Spring Social Showcase to see how ProviderSignInUtils.handlePostSignUp() is used. You just need to give it the user's local application user ID and the request. If there's a signin attempt in the session it will use it to complete the connection; otherwise it will do nothing.
    Last edited by habuma; Aug 23rd, 2011, 09:57 AM.

    Comment


    • #3
      Originally posted by habuma View Post
      If I'm following your description correctly, I think you might be able to do what you want to do by calling ProviderSignInUtils.handlePostSignUp() just like your signup controller should do after a new user registers with your application.
      Wow. That seems to be working perfectly. Thanks!

      Just to clarify my understanding, the reason it works without needing to call the ConnectController (/connect/facebook) is that the initial signin attempt managed to get the handle to facebook tied to the application (in handleSignIn of ProviderSigInController?)

      Side note: I'm normally not a big fan of UML but I'm curious if there is a nice sequence diagram that shows all these moving parts? If not, I'm going to work on one myself since I'm often getting lost of where certain things are being handled. Attaching the source code in the debugger is helping, but it's slow going.)

      Comment


      • #4
        When ProviderSignInController failed to find a local account connected to the Facebook account, it stowed the Facebook connection details in the session and then redirected to the signup page. Once the user signs up (or in your case, signs in) calling ProviderSignInUtils.handlePostSignUp() will fetch those connection details from the session and use them to finalize the connection with the given user.

        Comment

        Working...
        X