I'm experiencing some strange behavior in my nodeBB forum that is closed for guests.
In some groups there is the user guest (German: Gast) added as a member and cannot be kicked. Everytime I kick him he is still there, but the member count reduces by one and is not correct anymore. Is there any way to force a recalculation of the member counts?
In some other groups the user guest does not appear as a member in the members list, but he appears on the groups overview page.
I have to admit that the users of my forum were created automatically at login (if not existing already) via User.create() function. I can see in the Redis database that sometimes a user uid:null
is created although my authorization plugin shouldn't create such user. The users will be automatically assigend to their respective groups by the plugin as well. This process might be the reason of the strange behavior, but I don't know what is wrong with my script. Have a look at the relevant snippet below:
//...
var User = module.parent.require('./user'),
Groups = module.parent.require('./groups'),
Auth = {};
Auth.tryLogin = // ...
Auth.login = function() {
passport.use(new passportLocal({passReqToCallback: true}, Auth.continueLogin));
};
Auth.continueLogin = function(req, username, password, next) {
Auth.tryLogin(username.toLowerCase(), password, function(err, loginUser) {
if (err) {
next(err);
} else {
User.getUidByUsername(username.toLowerCase(), function(err2, uid) {
if (err2) { next(err2); }
else {
if (!uid) {
User.create({ username: loginUser.username.toLowerCase(), email: loginUser.email }, function(err3, u) {
if (err3) { next(err3); }
uid = u;
});
}
// ...
loginUser.groups.forEach(function (group) {
Groups.join(group.name, uid);
}
next(null, { uid: uid }, '[[success:authentication-successful]]');
}
});
}
});
});
module.exports = Auth;
// ...