refactor: remove "password" in comments

This commit is contained in:
Barış Soner Uşaklı
2024-12-09 14:40:49 -05:00
parent e532dcb46c
commit fe811537e9
8 changed files with 5 additions and 16 deletions

View File

@@ -67,8 +67,8 @@ usersAPI.update = async function (caller, data) {
privileges.users.canEdit(caller.uid, data.uid), privileges.users.canEdit(caller.uid, data.uid),
]); ]);
// Changing own email/username requires password confirmation const isChangingEmailOrUsername = data.hasOwnProperty('email') || data.hasOwnProperty('username');
if (data.hasOwnProperty('email') || data.hasOwnProperty('username')) { if (isChangingEmailOrUsername) {
await isPrivilegedOrSelfAndPasswordMatch(caller, data); await isPrivilegedOrSelfAndPasswordMatch(caller, data);
} }
@@ -547,7 +547,6 @@ async function processDeletion({ uid, method, password, caller }) {
throw new Error('[[error:no-privileges]]'); throw new Error('[[error:no-privileges]]');
} }
// Self-deletions require a password
const hasPassword = await user.hasPassword(uid); const hasPassword = await user.hasPassword(uid);
if (isSelf && hasPassword) { if (isSelf && hasPassword) {
const ok = await user.isPasswordCorrect(uid, password, caller.ip); const ok = await user.isPasswordCorrect(uid, password, caller.ip);

View File

@@ -51,8 +51,7 @@ async function setup(initConfig) {
} }
console.log('NodeBB Setup Completed. Run "./nodebb start" to manually start your NodeBB server.'); console.log('NodeBB Setup Completed. Run "./nodebb start" to manually start your NodeBB server.');
// If I am a child process, notify the parent of the returned data before exiting (useful for notifying // If I am a child process, notify the parent of the returned data before exiting (useful for notifying hosts during headless setups)
// hosts of auto-generated username/password during headless setups)
if (process.send) { if (process.send) {
process.send(data); process.send(data);
} }

View File

@@ -370,26 +370,21 @@ async function createAdmin() {
} }
async function retryPassword(originalResults) { async function retryPassword(originalResults) {
// Ask only the password questions
const results = await prompt.get(passwordQuestions); const results = await prompt.get(passwordQuestions);
// Update the original data with newly collected password
originalResults.password = results.password; originalResults.password = results.password;
originalResults['password:confirm'] = results['password:confirm']; originalResults['password:confirm'] = results['password:confirm'];
// Send back to success to handle
return await success(originalResults); return await success(originalResults);
} }
// Add the password questions
questions = questions.concat(passwordQuestions); questions = questions.concat(passwordQuestions);
if (!install.values) { if (!install.values) {
const results = await prompt.get(questions); const results = await prompt.get(questions);
return await success(results); return await success(results);
} }
// If automated setup did not provide a user password, generate one,
// it will be shown to the user upon setup completion
if (!install.values.hasOwnProperty('admin:password') && !nconf.get('admin:password')) { if (!install.values.hasOwnProperty('admin:password') && !nconf.get('admin:password')) {
console.log('Password was not provided during automated setup, generating one...'); console.log('Password was not provided during automated setup, generating one...');
password = utils.generateUUID().slice(0, 8); password = utils.generateUUID().slice(0, 8);

View File

@@ -47,7 +47,6 @@ middleware.checkPrivileges = helpers.try(async (req, res, next) => {
} }
} }
// If user does not have password
const hasPassword = await user.hasPassword(req.uid); const hasPassword = await user.hasPassword(req.uid);
if (!hasPassword) { if (!hasPassword) {
return next(); return next();

View File

@@ -24,7 +24,6 @@ require('./user/status')(SocketUser);
require('./user/picture')(SocketUser); require('./user/picture')(SocketUser);
require('./user/registration')(SocketUser); require('./user/registration')(SocketUser);
// Password Reset
SocketUser.reset = {}; SocketUser.reset = {};
SocketUser.reset.send = async function (socket, email) { SocketUser.reset.send = async function (socket, email) {

View File

@@ -82,7 +82,6 @@ module.exports = function (User) {
if (!fields.length) { if (!fields.length) {
fields = results.whitelist; fields = results.whitelist;
} else { } else {
// Never allow password retrieval via this method
fields = fields.filter(value => value !== 'password'); fields = fields.filter(value => value !== 'password');
} }

View File

@@ -244,7 +244,7 @@ User.addInterstitials = function (callback) {
plugins.hooks.register('core', { plugins.hooks.register('core', {
hook: 'filter:register.interstitial', hook: 'filter:register.interstitial',
method: [ method: [
User.interstitials.email, // Email address (for password reset + digest) User.interstitials.email, // Email address
User.interstitials.gdpr, // GDPR information collection/processing consent + email consent User.interstitials.gdpr, // GDPR information collection/processing consent + email consent
User.interstitials.tou, // Forum Terms of Use User.interstitials.tou, // Forum Terms of Use
], ],

View File

@@ -108,7 +108,6 @@ UserReset.commit = async function (code, password) {
'password:shaWrapped': 1, 'password:shaWrapped': 1,
}; };
// don't verify email if password reset is due to expiry
const isPasswordExpired = userData.passwordExpiry && userData.passwordExpiry < Date.now(); const isPasswordExpired = userData.passwordExpiry && userData.passwordExpiry < Date.now();
if (!isPasswordExpired) { if (!isPasswordExpired) {
data['email:confirmed'] = 1; data['email:confirmed'] = 1;