mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-10 07:55:46 +01:00
@@ -57,7 +57,7 @@ usersAPI.update = async function (caller, data) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
|
||||
const oldUserData = await user.getUserFields(data.uid, ['email', 'username']);
|
||||
const oldUserData = await db.getObjectFields(`user:${data.uid}`, ['email', 'username']);
|
||||
if (!oldUserData || !oldUserData.username) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
@@ -86,14 +86,14 @@ usersAPI.update = async function (caller, data) {
|
||||
|
||||
await user.updateProfile(caller.uid, data);
|
||||
const userData = await user.getUserData(data.uid);
|
||||
|
||||
if (userData.username !== oldUserData.username) {
|
||||
const oldUsernameEscaped = validator.escape(String(oldUserData.username));
|
||||
if (userData.username !== oldUsernameEscaped) {
|
||||
await events.log({
|
||||
type: 'username-change',
|
||||
uid: caller.uid,
|
||||
targetUid: data.uid,
|
||||
ip: caller.ip,
|
||||
oldUsername: oldUserData.username,
|
||||
oldUsername: oldUsernameEscaped,
|
||||
newUsername: userData.username,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user