mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 00:56:13 +01:00
* feat: add displayname into user obj #8637 * fix: spec * perf: dont load settings if acp setting is turned off
This commit is contained in:
committed by
GitHub
parent
8d060065a0
commit
9ca44e6f54
@@ -114,6 +114,7 @@
|
|||||||
"email:smtpTransport:pool": false,
|
"email:smtpTransport:pool": false,
|
||||||
"hideFullname": 0,
|
"hideFullname": 0,
|
||||||
"hideEmail": 0,
|
"hideEmail": 0,
|
||||||
|
"showFullnameAsDisplayName": 0,
|
||||||
"allowGuestHandles": 0,
|
"allowGuestHandles": 0,
|
||||||
"guestsIncrementTopicViews": 1,
|
"guestsIncrementTopicViews": 1,
|
||||||
"allowGuestReplyNotifications": 1,
|
"allowGuestReplyNotifications": 1,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
"allow-account-deletion": "Allow account deletion",
|
"allow-account-deletion": "Allow account deletion",
|
||||||
"hide-fullname": "Hide fullname from users",
|
"hide-fullname": "Hide fullname from users",
|
||||||
"hide-email": "Hide email from users",
|
"hide-email": "Hide email from users",
|
||||||
|
"show-fullname-as-displayname": "Show user's full name as their display name if available",
|
||||||
"themes": "Themes",
|
"themes": "Themes",
|
||||||
"disable-user-skins": "Prevent users from choosing a custom skin",
|
"disable-user-skins": "Prevent users from choosing a custom skin",
|
||||||
"account-protection": "Account Protection",
|
"account-protection": "Account Protection",
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ PostObject:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
|
|||||||
@@ -89,6 +89,9 @@ TopicObject:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
fullname:
|
fullname:
|
||||||
type: string
|
type: string
|
||||||
userslug:
|
userslug:
|
||||||
|
|||||||
@@ -27,6 +27,10 @@ UserObj:
|
|||||||
fullname:
|
fullname:
|
||||||
type: string
|
type: string
|
||||||
example: Mr. Dragon Fruit Jr.
|
example: Mr. Dragon Fruit Jr.
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
|
example: Dragon Fruit
|
||||||
location:
|
location:
|
||||||
type: string
|
type: string
|
||||||
example: 'Toronto, Canada'
|
example: 'Toronto, Canada'
|
||||||
|
|||||||
@@ -37,6 +37,10 @@ UserObject:
|
|||||||
fullname:
|
fullname:
|
||||||
type: string
|
type: string
|
||||||
example: Mr. Dragon Fruit Jr.
|
example: Mr. Dragon Fruit Jr.
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
|
example: Dragon Fruit
|
||||||
location:
|
location:
|
||||||
type: string
|
type: string
|
||||||
example: 'Toronto, Canada'
|
example: 'Toronto, Canada'
|
||||||
@@ -227,6 +231,10 @@ UserObjectFull:
|
|||||||
fullname:
|
fullname:
|
||||||
type: string
|
type: string
|
||||||
example: Mr. Dragon Fruit Jr.
|
example: Mr. Dragon Fruit Jr.
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
|
example: Dragon Fruit
|
||||||
location:
|
location:
|
||||||
type: string
|
type: string
|
||||||
example: 'Toronto, Canada'
|
example: 'Toronto, Canada'
|
||||||
@@ -463,6 +471,10 @@ UserObjectSlim:
|
|||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
example: Dragon Fruit
|
example: Dragon Fruit
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
|
example: Dragon Fruit
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces removed, etc.)
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces removed, etc.)
|
||||||
@@ -544,6 +556,10 @@ UserObjectACP:
|
|||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
example: Dragon Fruit
|
example: Dragon Fruit
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
|
example: Dragon Fruit
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces removed, etc.)
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces removed, etc.)
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
picture:
|
picture:
|
||||||
nullable: true
|
nullable: true
|
||||||
type: string
|
type: string
|
||||||
|
|||||||
@@ -150,6 +150,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
|
|||||||
@@ -77,6 +77,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
@@ -160,6 +163,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
|
|||||||
@@ -83,6 +83,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
@@ -145,6 +148,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
|
|||||||
@@ -137,6 +137,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
|
|||||||
@@ -109,6 +109,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
fullname:
|
fullname:
|
||||||
type: string
|
type: string
|
||||||
userslug:
|
userslug:
|
||||||
|
|||||||
@@ -65,6 +65,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
@@ -115,6 +118,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
picture:
|
picture:
|
||||||
type: string
|
type: string
|
||||||
nullable: true
|
nullable: true
|
||||||
@@ -171,6 +177,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
@@ -221,6 +230,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
@@ -256,6 +268,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ get:
|
|||||||
username:
|
username:
|
||||||
type: string
|
type: string
|
||||||
description: A friendly name for a given user account
|
description: A friendly name for a given user account
|
||||||
|
displayname:
|
||||||
|
type: string
|
||||||
|
description: This is either username or fullname depending on forum and user settings
|
||||||
userslug:
|
userslug:
|
||||||
type: string
|
type: string
|
||||||
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
description: An URL-safe variant of the username (i.e. lower-cased, spaces
|
||||||
|
|||||||
@@ -136,6 +136,15 @@ module.exports = function (User) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
async function modifyUserData(users, requestedFields, fieldsToRemove) {
|
async function modifyUserData(users, requestedFields, fieldsToRemove) {
|
||||||
|
let uidToSettings = {};
|
||||||
|
if (meta.config.showFullnameAsDisplayName) {
|
||||||
|
const uids = _.uniq(users.map(user => user.uid));
|
||||||
|
uidToSettings = _.zipObject(uids, await db.getObjectsFields(
|
||||||
|
uids.map(uid => 'user:' + uid + ':settings'),
|
||||||
|
['showfullname']
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
users = await Promise.all(users.map(async function (user) {
|
users = await Promise.all(users.map(async function (user) {
|
||||||
if (!user) {
|
if (!user) {
|
||||||
return user;
|
return user;
|
||||||
@@ -144,6 +153,16 @@ module.exports = function (User) {
|
|||||||
db.parseIntFields(user, intFields, requestedFields);
|
db.parseIntFields(user, intFields, requestedFields);
|
||||||
|
|
||||||
if (user.hasOwnProperty('username')) {
|
if (user.hasOwnProperty('username')) {
|
||||||
|
let showfullname = parseInt(meta.config.showfullname, 10) === 1;
|
||||||
|
if (uidToSettings[user.uid] && parseInt(uidToSettings[user.uid].showfullname, 10) === 0) {
|
||||||
|
showfullname = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
user.displayname = validator.escape(String(
|
||||||
|
meta.config.showFullnameAsDisplayName && showfullname && user.fullname ?
|
||||||
|
user.fullname :
|
||||||
|
user.username
|
||||||
|
));
|
||||||
user.username = validator.escape(user.username ? user.username.toString() : '');
|
user.username = validator.escape(user.username ? user.username.toString() : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,12 @@
|
|||||||
<span class="mdl-switch__label"><strong>[[admin/settings/user:hide-email]]</strong></span>
|
<span class="mdl-switch__label"><strong>[[admin/settings/user:hide-email]]</strong></span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="checkbox">
|
||||||
|
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
|
||||||
|
<input class="mdl-switch__input" type="checkbox" data-field="showFullnameAsDisplayName">
|
||||||
|
<span class="mdl-switch__label"><strong>[[admin/settings/user:show-fullname-as-displayname]]</strong></span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user