fix: expose remote url in user object

This commit is contained in:
Julian Lam
2025-03-07 13:26:33 -05:00
parent f8a2cd7a4d
commit 78c9239b22
3 changed files with 9 additions and 2 deletions

View File

@@ -108,7 +108,7 @@
"nodebb-plugin-spam-be-gone": "2.3.1",
"nodebb-plugin-web-push": "0.7.3",
"nodebb-rewards-essentials": "1.0.1",
"nodebb-theme-harmony": "2.0.39",
"nodebb-theme-harmony": "2.0.40",
"nodebb-theme-lavender": "7.1.18",
"nodebb-theme-peace": "2.2.39",
"nodebb-theme-persona": "14.0.16",

View File

@@ -61,6 +61,7 @@
"chat": "Chat",
"chat-with": "Continue chat with %1",
"new-chat-with": "Start new chat with %1",
"view-remote": "View Original",
"flag-profile": "Flag Profile",
"profile-flagged": "Already flagged",
"follow": "Follow",

View File

@@ -21,7 +21,7 @@ const intFields = [
module.exports = function (User) {
const fieldWhitelist = [
'uid', 'username', 'userslug', 'email', 'email:confirmed', 'joindate',
'uid', 'username', 'userslug', 'url', 'email', 'email:confirmed', 'joindate',
'lastonline', 'picture', 'icon:bgColor', 'fullname', 'birthday',
'aboutme', 'signature', 'uploadedpicture', 'profileviews', 'reputation',
'postcount', 'topiccount', 'lastposttime', 'banned', 'banned:expire',
@@ -235,6 +235,12 @@ module.exports = function (User) {
user.username = validator.escape(user.username ? user.username.toString() : '');
}
if (user.hasOwnProperty('url')) {
// works around renderOverride supplying `url` to templates
user.remoteUrl = user.url;
delete user.url;
}
if (user.hasOwnProperty('email')) {
user.email = validator.escape(user.email ? user.email.toString() : '');
}