Skip to content

Commit

Permalink
feat: removal of emailExists socket listener
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Jul 30, 2021
1 parent 04b1f70 commit 12b2a97
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 46 deletions.
18 changes: 2 additions & 16 deletions public/src/client/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 0 additions & 7 deletions src/socket.io/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]]');
Expand Down
23 changes: 0 additions & 23 deletions test/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]]');
Expand Down

0 comments on commit 12b2a97

Please sign in to comment.