Results 1 to 7 of 7

Thread: Extending UserProfile on signup

  1. #1
    Join Date
    Jul 2008
    Posts
    116

    Default Extending UserProfile on signup

    Hi

    I have configured the signup controller with Facebook for my application. There is only one last thing I wish to do to it. When the user signs up with Facebook, they implicitly get an account created on our site if it doesn't already exist. Our user object wants a locale at the time of registration. I see locale is available on the user profile using the FB graph api, but it is not available in the UserProfile object that I pass to my implementation of ConnectionSignUp. I looked around for some way of intercepting this, but there is no real way for me to get a handle on the Facebook class until I have persisted the user and made him available in the users repository.

    So my question is: Is there a way for me to extend UserProfile so I can set locale or is this something I should ask for as a new feature from you guys?

    Cheers
    bjorn

  2. #2
    Join Date
    Aug 2011
    Posts
    3

    Default

    I would like to see this as a new feature also.

  3. #3

    Default

    I asked for something similar back when the M1 came out. Keith had asked the details of my requirement. I thought it would come with M2. Very disappointed the feature is not even in the formal release more than six month later. Don't understand know why this feature can't be in the release.
    [URL="http://vicina.info"] 新闻,社区新闻,分类广告

  4. #4
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default

    It's not the cleanest, but you could call connection.getApi() inside your ConnectionSignUp implementation, test if it's Facebook, and do get the locale that way, yes? I think we should take a look at the normalized UserProfile abstraction, see what profile fields are common across providers we currently do not model, and add them... I assume "locale" is one but there are likely others.

    As for "I asked for something in the M1 timeframe, and am upset it's not in there now" - that was a long time ago - there's been a lot of work going on since then, and many discussions. Please don't expect something you want in the framework to be just handed to you on some kind of platter. You're much more likely to get results if you take time to work closely with the team in a positive, collaborative manner. This can be done by having discussions here, in JIRA issues, and on github via its social coding / forking & pull request infrastructure.

    Keith
    Last edited by Keith Donald; Sep 18th, 2011 at 11:12 PM.
    Keith Donald
    Core Spring Development Team

  5. #5
    Join Date
    Aug 2004
    Posts
    1,099

    Default

    Facebook does include a locale field in its user profile data. Twitter, as far as I can tell, only includes the language and not the country code. In contrast, LinkedIn includes the country code, but not the language (at least so far as I can tell from looking at my standard LinkedIn profile). Surprisingly, neither TripIt nor Gowalla provide any sort of locale information. If we were to add this to UserProfile, we should consider having 2 distinct fields for country and language, either of which is optional and could be null.

    As Keith mentioned, there are likely other somewhat common fields that could be added to UserProfile. I've created https://jira.springsource.org/browse/SOCIAL-253 to track this work and provide a place for further discussion.
    Craig Walls
    Spring Social Project Lead

  6. #6
    Join Date
    Jul 2007
    Location
    Mauritius
    Posts
    128

    Default

    Keith,

    you mentioned that there is a way to use the connection.getApi() by first testing if its Facebook. Can you please give me some implementation tip on how you can do that.

    The way I am doing it is as follows:


    public class SimpleConnectionSignUp implements ConnectionSignUp {

    private static final Logger LOGGER = Logger.getLogger(SimpleConnectionSignUp.class);

    public String execute(Connection<?> connection) {

    FacebookTemplate facebookTemplate = (FacebookTemplate) connection.getApi();

    return facebookTemplate.userOperations().getUserProfile() .getEmail();



    However, the error I get is as follows

    SEVERE: Servlet.service() for servlet Spring MVC Dispatcher Servlet threw exception
    java.lang.ClassCastException: $Proxy44 cannot be cast to org.springframework.social.facebook.api.impl.Faceb ookTemplate


    Thanks for your help.

    Cheers
    Kris

  7. #7
    Join Date
    Apr 2010
    Posts
    11

    Default

    Hi,

    Is there any updates on this? I would like to get the birthday. I'm able to get it from FB scope, but not in the UserProfile. I think a work around for now is to try to "fetch" that field separately. I returns in the scope JSON in the logs, but no serialization is taking place anywhere I can see.

    Is there a ticket for this? If possible I can contribute to this since I'm already working on it. Thanks and I look forward to your reply!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •