How do I set default values for users after SSO?

Solved General Discussion
  • I'm using the custom SSO plugin found here: (with a few alterations). Inside the parseUserReturn function, I'm trying to set their default picture so:

    var profile = {};
    /* Required. */ =;
    profile.displayName =;
    profile.emails = [{ value: }];
    /* Optional. */
    profile.picture = data.avatar;
    callback(null, profile);

    However, it seems to be ignored. What am I doing wrong?

    I'm using NodeBB v0.7.3

    edit: I'd also like to set defaults on user:*:settings to have followTopicsOnReply and followTopicsOnCreate to 1 after a successful sign up via SSO. Is this something I can do?

  • Sure, so -- setting profile will only instruct the plugin to use the values as they are provided. After the user is created (that is, once you have a uid), you can reference the user library to do your own modifications:

    var user = module.parent.require('user');
    user.setUserField('picture', urlToPicture, function(err) {
        // ...
  • Thanks @julian.

    I was able to set the picture by extending the OAuth.login method (

    function _getAvatar(data) {
    var success = function (uid) {
      // Save provider-specific information to the user
      User.setUserField(uid, + 'Id', payload.oAuthid);
      db.setObjectField( + 'Id:uid', payload.oAuthid, uid);
      var avatar = _getAvatar(;
      if (avatar) {
        User.setUserField(uid, 'picture', avatar);
        User.setUserField(uid, 'uploadedpicture', avatar);

    I'm not sure why but just updating the picture didn't seem to work. I had to update uploadedpicture as well.

    The other thing I needed to do was change the settings. Turns out that user:*:settings isn't fully populated until I visit the settings page and click on "save settings". So what I ended up having to do was:

    var mySettings = {};   // Custom settings.
    User.saveSettings(uid, mySettings, function (err) {});

    and that seemed to work.

  • Thanks for checking back in! 😄

Suggested Topics