breaking: remove socket.emit('user.changeUsernameEmail')

remove socket.emit('user.changePassword')
remove socket.emit('user.updateProfile')
This commit is contained in:
Barış Soner Uşaklı
2021-12-13 20:10:45 -05:00
parent cc0a087a70
commit 6b45dee9c5
3 changed files with 93 additions and 169 deletions

View File

@@ -44,7 +44,7 @@ usersAPI.update = async function (caller, data) {
]);
// Changing own email/username requires password confirmation
if (['email', 'username'].some(prop => Object.keys(data).includes(prop))) {
if (data.hasOwnProperty('email') || data.hasOwnProperty('username')) {
await isPrivilegedOrSelfAndPasswordMatch(caller, data);
}
@@ -63,16 +63,15 @@ usersAPI.update = async function (caller, data) {
await user.updateProfile(caller.uid, data);
const userData = await user.getUserData(data.uid);
async function log(type, eventData) {
eventData.type = type;
eventData.uid = caller.uid;
eventData.targetUid = data.uid;
eventData.ip = caller.ip;
await events.log(eventData);
}
if (userData.username !== oldUserData.username) {
await log('username-change', { oldUsername: oldUserData.username, newUsername: userData.username });
await events.log({
type: 'username-change',
uid: caller.uid,
targetUid: data.uid,
ip: caller.ip,
oldUsername: oldUserData.username,
newUsername: userData.username,
});
}
return userData;
};