fix: #9394, fix guest handles

This commit is contained in:
Barış Soner Uşaklı
2021-03-15 14:03:35 -04:00
parent d1685600d3
commit eb360351e5
5 changed files with 57 additions and 8 deletions

View File

@@ -53,6 +53,16 @@ module.exports = function (Posts) {
}));
};
Posts.overrideGuestHandle = function (postData, handle) {
if (meta.config.allowGuestHandles && postData && postData.user && parseInt(postData.uid, 10) === 0 && handle) {
postData.user.username = validator.escape(String(handle));
if (postData.user.hasOwnProperty('fullname')) {
postData.user.fullname = postData.user.username;
}
postData.user.displayname = postData.user.username;
}
};
async function checkGroupMembership(uid, groupTitleArray) {
if (!Array.isArray(groupTitleArray) || !groupTitleArray.length) {
return null;