fix: ability to enumerate email via updateProfile method

isekai-main
Julian Lam 3 years ago
parent b912a564e3
commit c1ac291284

@ -71,7 +71,7 @@ module.exports = function (User) {
}; };
async function validateData(callerUid, data) { async function validateData(callerUid, data) {
await isEmailAvailable(data, data.uid); await isEmailValid(data);
await isUsernameAvailable(data, data.uid); await isUsernameAvailable(data, data.uid);
await isWebsiteValid(callerUid, data); await isWebsiteValid(callerUid, data);
await isAboutMeValid(callerUid, data); await isAboutMeValid(callerUid, data);
@ -82,7 +82,7 @@ module.exports = function (User) {
isGroupTitleValid(data); isGroupTitleValid(data);
} }
async function isEmailAvailable(data, uid) { async function isEmailValid(data) {
if (!data.email) { if (!data.email) {
return; return;
} }
@ -91,14 +91,6 @@ module.exports = function (User) {
if (!utils.isEmailValid(data.email)) { if (!utils.isEmailValid(data.email)) {
throw new Error('[[error:invalid-email]]'); throw new Error('[[error:invalid-email]]');
} }
const email = await User.getUserField(uid, 'email');
if (email === data.email) {
return;
}
const available = await User.email.available(data.email);
if (!available) {
throw new Error('[[error:email-taken]]');
}
} }
async function isUsernameAvailable(data, uid) { async function isUsernameAvailable(data, uid) {

Loading…
Cancel
Save