mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
add groupTitle test for guests
This commit is contained in:
@@ -141,9 +141,6 @@ module.exports = function (User) {
|
||||
|
||||
db.parseIntFields(user, intFields, requestedFields);
|
||||
|
||||
if (user.hasOwnProperty('groupTitle')) {
|
||||
parseGroupTitle(user);
|
||||
}
|
||||
if (user.hasOwnProperty('username')) {
|
||||
user.username = validator.escape(user.username ? user.username.toString() : '');
|
||||
}
|
||||
@@ -155,6 +152,11 @@ module.exports = function (User) {
|
||||
user.picture = User.getDefaultAvatar();
|
||||
user['icon:text'] = '?';
|
||||
user['icon:bgColor'] = '#aaa';
|
||||
user.groupTitle = '';
|
||||
}
|
||||
|
||||
if (user.hasOwnProperty('groupTitle')) {
|
||||
parseGroupTitle(user);
|
||||
}
|
||||
|
||||
if (user.picture && user.picture === user.uploadedpicture) {
|
||||
@@ -204,12 +206,20 @@ module.exports = function (User) {
|
||||
try {
|
||||
user.groupTitleArray = JSON.parse(user.groupTitle);
|
||||
} catch (err) {
|
||||
if (user.groupTitle) {
|
||||
user.groupTitleArray = [user.groupTitle];
|
||||
} else {
|
||||
user.groupTitleArray = [];
|
||||
}
|
||||
}
|
||||
if (!Array.isArray(user.groupTitleArray)) {
|
||||
if (user.groupTitleArray) {
|
||||
user.groupTitleArray = [user.groupTitleArray];
|
||||
} else {
|
||||
user.groupTitleArray = [];
|
||||
}
|
||||
if (!meta.config.allowMultipleBadges) {
|
||||
}
|
||||
if (!meta.config.allowMultipleBadges && user.groupTitleArray.length) {
|
||||
user.groupTitleArray = [user.groupTitleArray[0]];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -605,6 +605,15 @@ describe('User', function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not get groupTitle for guests', function (done) {
|
||||
User.getUserData(0, function (err, userData) {
|
||||
assert.ifError(err);
|
||||
assert.strictEqual(userData.groupTitle, '');
|
||||
assert.deepStrictEqual(userData.groupTitleArray, []);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('not logged in', function () {
|
||||
|
||||
Reference in New Issue
Block a user