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

  • 0 Votes
    4 Posts
  • 0 Votes
    3 Posts

    @PitaJ said in NodeBB custom Javascript check current user groups:

    You can use Ajax to request their user page, and in the json it should specify all of the groups they're in.

    ah sorry forgot to reply here,
    meantime I found out, that its not a problem in custom JS to use app.user.groupTitle 🙂
    it works fine so good

  • 0 Votes
    1 Posts

    @bentael said in away, busy invisible etc. UserStates:

    away - when user is online but no activity for an X amount of time.
    busy - set by user
    invisible - set by user


    Currently, it seems that the 'away' state is not auto-enabled when user has no activity for a certain amount of time :

    If it is really the case, wouldn't be greater like this ? (in fact, I need this functionality but don't see it working... Found no code about this in nodebb source code). If it is not the case, what is the time amount for status change to 'away' ? Can it be changed ?

    @administrators : Add on... Would it be possible to have the following operating mode for statuses (more realtime, with, like smart messaging apps) ? When a user is previously logged in nodebb :

    If he makes actions on nodebb (open a page, posting, typing, scrolling...) and if he is not in 'dnd' or 'invisible' or already 'online' mode, auto-set him in 'online' status and update status on all connected clients (update widgets etc...). If he doesn't do anything for a while and if he is not in 'dnd' or 'invisible' or already 'away' mode, auto-set him in 'away' status and update status on all connected clients. If socket connexion is lost, auto-set him in 'offline' status and update status on all connected clients. If socket connexion is reconnected, auto-set him in its previous status and update it on all connected clients.


    In short, knowing in a more realtime status of the users would be a big plus for nodebb. I know it can be ressources consuming but there may be a trick with (?).

    Another thing : online-cutoff time seems too restrictive for me. If a user is inactive more than this time, he should go into 'away' state but he could always receive notifications because he is not offline. There could be a different time to cut notifications...

    (sorry for this long post ! Hope I'm clear ; I'm french... 😉 )

  • 0 Votes
    1 Posts

    the user's personal information in the pictures below , such as the number of posts, reputation and so on. any plugin?who knows?

  • 0 Votes
    5 Posts

    What I see as beneficial is a core feature (or a plugin I supposed) that exposes the database (read-only -- either Redis or Mongodb) keys in such a way that an administrator could create his own search queries with desired results.

    I envision a picker of the thing that can be searched, a way to filter the results and then a picker on what fields should be displayed.

    Does something like this exist?