mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 11:35:55 +01:00
user fixes
This commit is contained in:
@@ -139,8 +139,8 @@ Sockets.init = function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
console.log('derp');
|
||||
console.log(payload, callback);
|
||||
var parts = payload.name.split('.'),
|
||||
namespace = parts.slice(0, 1),
|
||||
methodToCall = parts.reduce(function(prev, cur) {
|
||||
|
||||
@@ -5,11 +5,7 @@ var user = require('../user'),
|
||||
|
||||
SocketUser.exists = function(socket, data, callback) {
|
||||
if (data && data.username) {
|
||||
user.exists(utils.slugify(data.username), function(exists) {
|
||||
socket.emit('user.exists', {
|
||||
exists: exists
|
||||
});
|
||||
});
|
||||
user.exists(utils.slugify(data.username), callback);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
29
src/user.js
29
src/user.js
@@ -46,7 +46,10 @@ var bcrypt = require('bcrypt'),
|
||||
}
|
||||
},
|
||||
function(next) {
|
||||
User.exists(userslug, function(exists) {
|
||||
User.exists(userslug, function(err, exists) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
next(exists ? new Error('Username taken!') : null);
|
||||
});
|
||||
},
|
||||
@@ -193,9 +196,7 @@ var bcrypt = require('bcrypt'),
|
||||
|
||||
function isSignatureValid(next) {
|
||||
if (data.signature !== undefined && data.signature.length > meta.config.maximumSignatureLength) {
|
||||
next({
|
||||
error: 'Signature can\'t be longer than ' + meta.config.maximumSignatureLength + ' characters!'
|
||||
}, false);
|
||||
next(new Error('Signature can\'t be longer than ' + meta.config.maximumSignatureLength + ' characters!'), false);
|
||||
} else {
|
||||
next(null, true);
|
||||
}
|
||||
@@ -217,9 +218,7 @@ var bcrypt = require('bcrypt'),
|
||||
}
|
||||
|
||||
if (!available) {
|
||||
next({
|
||||
error: 'Email not available!'
|
||||
}, false);
|
||||
next(new Error('Email not available!'), false);
|
||||
} else {
|
||||
next(null, true);
|
||||
}
|
||||
@@ -237,16 +236,16 @@ var bcrypt = require('bcrypt'),
|
||||
}
|
||||
|
||||
if(!utils.isUserNameValid(data.username) || !userslug) {
|
||||
return next({
|
||||
error: 'Invalid Username!'
|
||||
}, false);
|
||||
return next(new Error('Invalid Username!'), false);
|
||||
}
|
||||
|
||||
User.exists(userslug, function(err, exists) {
|
||||
if(err) {
|
||||
return next(err);
|
||||
}
|
||||
|
||||
User.exists(userslug, function(exists) {
|
||||
if(exists) {
|
||||
next({
|
||||
error: 'Username not available!'
|
||||
}, false);
|
||||
next(new Error('Username not available!'), false);
|
||||
} else {
|
||||
next(null, true);
|
||||
}
|
||||
@@ -667,7 +666,7 @@ var bcrypt = require('bcrypt'),
|
||||
|
||||
User.exists = function(userslug, callback) {
|
||||
User.getUidByUserslug(userslug, function(err, exists) {
|
||||
callback( !! exists);
|
||||
callback(err, !! exists);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user