|
|
|
@ -23,14 +23,15 @@ require('./user/picture')(SocketUser);
|
|
|
|
|
require('./user/ban')(SocketUser);
|
|
|
|
|
|
|
|
|
|
SocketUser.exists = function(socket, data, callback) {
|
|
|
|
|
if (data && data.username) {
|
|
|
|
|
meta.userOrGroupExists(data.username, callback);
|
|
|
|
|
if (!data || !data.username) {
|
|
|
|
|
return callback(new Error('[[error:invalid-data]]'));
|
|
|
|
|
}
|
|
|
|
|
meta.userOrGroupExists(data.username, callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SocketUser.deleteAccount = function(socket, data, callback) {
|
|
|
|
|
if (!socket.uid) {
|
|
|
|
|
return;
|
|
|
|
|
return callback(new Error('[[error:no-privileges]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async.waterfall([
|
|
|
|
@ -58,25 +59,27 @@ SocketUser.deleteAccount = function(socket, data, callback) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SocketUser.emailExists = function(socket, data, callback) {
|
|
|
|
|
if (data && data.email) {
|
|
|
|
|
user.email.exists(data.email, callback);
|
|
|
|
|
if (!data || !data.email) {
|
|
|
|
|
return callback(new Error('[[error:invalid-data]]'));
|
|
|
|
|
}
|
|
|
|
|
user.email.exists(data.email, callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SocketUser.emailConfirm = function(socket, data, callback) {
|
|
|
|
|
if (socket.uid && parseInt(meta.config.requireEmailConfirmation, 10) === 1) {
|
|
|
|
|
user.getUserField(socket.uid, 'email', function(err, email) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!email) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (!socket.uid) {
|
|
|
|
|
return callback(new Error('[[error:no-privileges]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
user.email.sendValidationEmail(socket.uid, email, callback);
|
|
|
|
|
});
|
|
|
|
|
if (parseInt(meta.config.requireEmailConfirmation, 10) !== 1) {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
user.getUserField(socket.uid, 'email', function(err, email) {
|
|
|
|
|
if (err || !email) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
user.email.sendValidationEmail(socket.uid, email, callback);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -84,9 +87,11 @@ SocketUser.emailConfirm = function(socket, data, callback) {
|
|
|
|
|
SocketUser.reset = {};
|
|
|
|
|
|
|
|
|
|
SocketUser.reset.send = function(socket, email, callback) {
|
|
|
|
|
if (email) {
|
|
|
|
|
user.reset.send(email, callback);
|
|
|
|
|
if (!email) {
|
|
|
|
|
return callback(new Error('[[error:invalid-data]]'));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
user.reset.send(email, callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SocketUser.reset.commit = function(socket, data, callback) {
|
|
|
|
@ -102,9 +107,9 @@ SocketUser.reset.commit = function(socket, data, callback) {
|
|
|
|
|
return callback(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var uid = results.uid,
|
|
|
|
|
now = new Date(),
|
|
|
|
|
parsedDate = now.getFullYear() + '/' + (now.getMonth()+1) + '/' + now.getDate();
|
|
|
|
|
var uid = results.uid;
|
|
|
|
|
var now = new Date();
|
|
|
|
|
var parsedDate = now.getFullYear() + '/' + (now.getMonth()+1) + '/' + now.getDate();
|
|
|
|
|
|
|
|
|
|
user.getUserField(uid, 'username', function(err, username) {
|
|
|
|
|
emailer.send('reset_notify', uid, {
|
|
|
|
@ -134,7 +139,7 @@ SocketUser.isFollowing = function(socket, data, callback) {
|
|
|
|
|
|
|
|
|
|
SocketUser.follow = function(socket, data, callback) {
|
|
|
|
|
if (!socket.uid || !data) {
|
|
|
|
|
return;
|
|
|
|
|
return callback(new Error('[[error:invalid-data]]'));
|
|
|
|
|
}
|
|
|
|
|
var userData;
|
|
|
|
|
async.waterfall([
|
|
|
|
@ -165,9 +170,10 @@ SocketUser.follow = function(socket, data, callback) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SocketUser.unfollow = function(socket, data, callback) {
|
|
|
|
|
if (socket.uid && data) {
|
|
|
|
|
toggleFollow('unfollow', socket.uid, data.uid, callback);
|
|
|
|
|
if (!socket.uid || !data) {
|
|
|
|
|
return callback(new Error('[[error:invalid-data]]'));
|
|
|
|
|
}
|
|
|
|
|
toggleFollow('unfollow', socket.uid, data.uid, callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function toggleFollow(method, uid, theiruid, callback) {
|
|
|
|
@ -206,15 +212,17 @@ SocketUser.saveSettings = function(socket, data, callback) {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SocketUser.setTopicSort = function(socket, sort, callback) {
|
|
|
|
|
if (socket.uid) {
|
|
|
|
|
user.setSetting(socket.uid, 'topicPostSort', sort, callback);
|
|
|
|
|
if (!socket.uid) {
|
|
|
|
|
return callback();
|
|
|
|
|
}
|
|
|
|
|
user.setSetting(socket.uid, 'topicPostSort', sort, callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SocketUser.setCategorySort = function(socket, sort, callback) {
|
|
|
|
|
if (socket.uid) {
|
|
|
|
|
user.setSetting(socket.uid, 'categoryTopicSort', sort, callback);
|
|
|
|
|
if (!socket.uid) {
|
|
|
|
|
return callback();
|
|
|
|
|
}
|
|
|
|
|
user.setSetting(socket.uid, 'categoryTopicSort', sort, callback);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
SocketUser.getUnreadCount = function(socket, data, callback) {
|
|
|
|
|