Announcement Announcement Module
Collapse
No announcement yet.
Social account changes Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Social account changes

    I have a website that uses the social stuff from spring social showcase example. I recently removed the username because I just want the the user to login using the email. This is working fine but I populate the email into the userConnection.userId column. If however the Facebook email is changed would this cause any problems?

    In the original example if the user changes his id (i think it is possible), would it be updated or would it just be outdated in the table or create a new row? Either way it might cause problem.

  • #2
    The UserConnection.UserId column must uniquely and definitively identify the local application user. Therefore, if you're using a volatile value such as an email address, then the connection will essentially be broken (an orphaned connection will remain in the table, though) for any user that changes their email address.

    Now...what you *could* do is let them change their email address, but also do a sweep through the UserConnection table to update their email there, too. That should work fine.

    But a better approach would be to never use a volatile value such as email. Instead have a primary key (perhaps a Long value) and refer to that in the UserConnection table. Then the user can change their email all they want, but their internal ID remains constant.

    Comment


    • #3
      I should have been more clear. When I mentioned users changing their email or username, I meant users changing it on Facebook or Twitter and not on my website. Would that create orphans, conflicts or would it update the existing connection records?

      I am just looking at this as a short term fix because it seems to be a smaller change and I didnt want users to have to select a username in an upcoming promotion.

      I am going to switch to the primary key approach. This field doesn't seem to be used in the authentication process. If I switch to the primary key as a foreign key, is there any possibility of breaking the auth process?

      Comment


      • #4
        The connection is based on the user's unique ID at Facebook/Twitter/whoever. In most (all?) cases, that is *not* their email address or other username. For example, my Facebook "username" is "habuma". But my Facebook ID is "738140579" and my email address is something else. I can change my email address or my user name, but unless I close my FB account and create a new one, my ID will always be "738140579".

        The UserConnection table contains a displayName that is usually set to the provider username, which depending on the provider could be their email address. That could change and it *could* go stale if it weren't for the fact that ProviderSignInController updates the connection after a successful sign-in. So, as long as the user is signing in via ProviderSignInController, their connection info will be up-to-date. You can also, at any point in your application code, get their connection data and update it via the connection repository if you want.

        You should switch to the primary key, and that key should be what is referenced in the UserConnection table's userId column. It will only break the auth process if you've already got some other field being referenced in that column. Just be sure to make changes to your sign in adapter to appropriately reference the right value.

        Comment


        • #5
          Originally posted by habuma View Post
          You should switch to the primary key
          I did this last night and it works fine.

          Originally posted by habuma View Post
          The UserConnection table contains a displayName that is usually set to the provider username, which depending on the provider could be their email address. That could change and it *could* go stale if it weren't for the fact that ProviderSignInController updates the connection after a successful sign-in. So, as long as the user is signing in via ProviderSignInController, their connection info will be up-to-date.
          Aha .. good to know. So I could use that as a displayName on my website so even though they don't select a username they can still have an updated name. If they have Twitter and Facebook connected, is there a way to tell which provider their current connection is so that I can use the appropriate displayName? I also see a rank on UserConnection, how is this determined? could I use this as a user preference for the displayName?

          Just found out that when I add a facebook connection after logging in locally it is adding the email. Could you point me to where this record is made in UserConnection so I can use the primary key instead?
          [update] ok I fixed this. The ConnectionRepository was being created with email instead of id. I just noticed one strange behavior. When the user logs out it creates a ConnectionRepository with id 'anonymousUser'. It seems unecessary but I left this as it is to avoid breaking anything else.
          Last edited by lilolme; Feb 7th, 2013, 08:45 PM. Reason: another question

          Comment

          Working...
          X