mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 08:36:12 +01:00
feat: removal of emailExists socket listener
This commit is contained in:
@@ -131,22 +131,8 @@ define('forum/register', [
|
||||
return callback();
|
||||
}
|
||||
|
||||
socket.emit('user.emailExists', {
|
||||
email: email,
|
||||
}, function (err, exists) {
|
||||
if (err) {
|
||||
app.alertError(err.message);
|
||||
return callback();
|
||||
}
|
||||
|
||||
if (exists) {
|
||||
showError(email_notify, '[[error:email-taken]]');
|
||||
} else {
|
||||
showSuccess(email_notify, successIcon);
|
||||
}
|
||||
|
||||
callback();
|
||||
});
|
||||
showSuccess(email_notify, successIcon);
|
||||
callback();
|
||||
}
|
||||
|
||||
function validateUsername(username, callback) {
|
||||
|
||||
@@ -43,13 +43,6 @@ SocketUser.deleteAccount = async function (socket, data) {
|
||||
await api.users.deleteAccount(socket, data);
|
||||
};
|
||||
|
||||
SocketUser.emailExists = async function (socket, data) {
|
||||
if (!data || !data.email) {
|
||||
throw new Error('[[error:invalid-data]]');
|
||||
}
|
||||
return await user.email.exists(data.email);
|
||||
};
|
||||
|
||||
SocketUser.emailConfirm = async function (socket) {
|
||||
if (!socket.uid) {
|
||||
throw new Error('[[error:no-privileges]]');
|
||||
|
||||
23
test/user.js
23
test/user.js
@@ -1766,29 +1766,6 @@ describe('User', () => {
|
||||
meta.config.allowAccountDeletion = oldValue;
|
||||
});
|
||||
|
||||
it('should fail if data is invalid', (done) => {
|
||||
socketUser.emailExists({ uid: testUid }, null, (err) => {
|
||||
assert.equal(err.message, '[[error:invalid-data]]');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return true if email exists', (done) => {
|
||||
socketUser.emailExists({ uid: testUid }, { email: 'john@example.com' }, (err, exists) => {
|
||||
assert.ifError(err);
|
||||
assert(exists);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should return false if email does not exist', (done) => {
|
||||
socketUser.emailExists({ uid: testUid }, { email: 'does@not.exist' }, (err, exists) => {
|
||||
assert.ifError(err);
|
||||
assert(!exists);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should error if requireEmailConfirmation is disabled', (done) => {
|
||||
socketUser.emailConfirm({ uid: testUid }, {}, (err) => {
|
||||
assert.equal(err.message, '[[error:email-confirmations-are-disabled]]');
|
||||
|
||||
Reference in New Issue
Block a user