PR feedback: Better handling of real name and email

This commit is contained in:
Bryan Ashby 2023-08-24 09:13:29 -06:00
parent 9205aaa9ee
commit 5a4563c799
8 changed files with 26 additions and 15 deletions

View File

@ -9,6 +9,7 @@ This document attempts to track **major** changes and additions in ENiGMA½. For
* Finally, the system will search for `index.html` and `index.htm` in that order, if another suitable route cannot be established. * Finally, the system will search for `index.html` and `index.htm` in that order, if another suitable route cannot be established.
* CombatNet has shut down, so the module (`combatnet.js`) has been removed. * CombatNet has shut down, so the module (`combatnet.js`) has been removed.
* The Menu Flag `popParent` has been removed and `noHistory` has been updated to work as expected. In general things should "Just Work", but check your `menu.hjson` entries if you see menu stack issues. * The Menu Flag `popParent` has been removed and `noHistory` has been updated to work as expected. In general things should "Just Work", but check your `menu.hjson` entries if you see menu stack issues.
* Various New User Application (NUA) properties are now optional. If you would like to reduce the information users are required, remove optional fields from NUA artwork and collect less. These properties will be stored as "" (empty). Optional properties are as follows: Real name, Birth date, Sex, Location, Affiliations (Affils), Email, and Web address.
## 0.0.13-beta ## 0.0.13-beta
* **Note for contributors**: ENiGMA has switched to [Prettier](https://prettier.io) for formatting/style. Please see [CONTRIBUTING](CONTRIBUTING.md) and the Prettier website for more information. * **Note for contributors**: ENiGMA has switched to [Prettier](https://prettier.io) for formatting/style. Please see [CONTRIBUTING](CONTRIBUTING.md) and the Prettier website for more information.

View File

@ -505,9 +505,9 @@ class Achievements {
getFormatObject(info) { getFormatObject(info) {
return { return {
userName: info.user.username, userName: info.user.username,
userRealName: info.user.realName(), userRealName: info.user.realName(false) || 'N/A',
userLocation: info.user.properties[UserProps.Location], userLocation: info.user.properties[UserProps.Location] || 'N/A',
userAffils: info.user.properties[UserProps.Affiliations], userAffils: info.user.properties[UserProps.Affiliations] || 'N/A',
nodeId: info.client.node, nodeId: info.client.node,
title: info.details.title, title: info.details.title,
//text : info.global ? info.details.globalText : info.details.text, //text : info.global ? info.details.globalText : info.details.text,

View File

@ -87,7 +87,7 @@ function getActiveConnectionList(
// //
entry.text = ac.user?.username || 'N/A'; entry.text = ac.user?.username || 'N/A';
entry.userName = ac.user?.username || 'N/A'; entry.userName = ac.user?.username || 'N/A';
entry.realName = ac.user?.realName() || 'N/A'; entry.realName = ac.user?.realName(false) || 'N/A';
entry.location = ac.user?.getProperty(UserProps.Location) || 'N/A'; entry.location = ac.user?.getProperty(UserProps.Location) || 'N/A';
entry.affils = entry.affiliation = entry.affils = entry.affiliation =
ac.user?.getProperty(UserProps.Affiliations) || 'N/A'; ac.user?.getProperty(UserProps.Affiliations) || 'N/A';

View File

@ -124,15 +124,29 @@ module.exports = class User {
return isMember; return isMember;
} }
realName() { realName(withUsernameFallback = true) {
return this.getProperty(UserProps.RealName) || this.username; const realName = this.getProperty(UserProps.RealName);
if (realName) {
return realName;
}
if (withUsernameFallback) {
return this.username;
}
} }
getSanitizedName(type = 'username') { getSanitizedName(type = 'username') {
const name = 'real' === type ? this.realName() : this.username; const name = 'real' === type ? this.realName(true) : this.username;
return sanatizeFilename(name) || `user${this.userId.toString()}`; return sanatizeFilename(name) || `user${this.userId.toString()}`;
} }
emailAddress() {
const email = this.getProperty(UserProps.EmailAddress);
if (email) {
const realName = this.realName(false);
return realName ? `${realName} <${email}>` : email;
}
}
isAvailable() { isAvailable() {
return (this.statusFlags & User.StatusFlags.NotAvailable) == 0; return (this.statusFlags & User.StatusFlags.NotAvailable) == 0;
} }

View File

@ -93,9 +93,7 @@ module.exports = class User2FA_OTPWebRegister {
} }
const message = { const message = {
to: `${user.realName()} <${user.getProperty( to: user.emailAddress(),
UserProps.EmailAddress
)}>`,
// from will be filled in // from will be filled in
subject: '2-Factor Authentication Registration', subject: '2-Factor Authentication Registration',
text: textTemplate, text: textTemplate,

View File

@ -233,7 +233,7 @@ exports.getModule = class UserConfigModule extends MenuModule {
function populateViews(callback) { function populateViews(callback) {
const user = self.client.user; const user = self.client.user;
self.setViewText('menu', MciCodeIds.RealName, user.realName()); self.setViewText('menu', MciCodeIds.RealName, user.realName(false) || '');
self.setViewText( self.setViewText(
'menu', 'menu',
MciCodeIds.BirthDate, MciCodeIds.BirthDate,

View File

@ -143,9 +143,7 @@ class WebPasswordReset {
} }
const message = { const message = {
to: `${user.realName()} <${ to: user.emailAddress(),
user.properties[UserProps.EmailAddress]
}>`,
// from will be filled in // from will be filled in
subject: 'Forgot Password', subject: 'Forgot Password',
text: textTemplate, text: textTemplate,

View File

@ -506,7 +506,7 @@ exports.getModule = class WaitingForCallerModule extends MenuModule {
// Current // Current
currentUserName: this.client.user.username, currentUserName: this.client.user.username,
currentUserRealName: this.client.user.realName(), currentUserRealName: this.client.user.realName(false) || 'N/A',
availIndicator: availIndicator, availIndicator: availIndicator,
visIndicator: visIndicator, visIndicator: visIndicator,
lastLoginUserName: lastLoginStats.userName, lastLoginUserName: lastLoginStats.userName,