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