mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-05-22 21:57:03 +00:00
Revert 215ca0371c
This commit is contained in:
parent
2883dc6c85
commit
7a2d2fd3dc
1 changed files with 3 additions and 4 deletions
|
|
@ -68,7 +68,6 @@ api.authWithUrl = function(req, res, next) {
|
|||
|
||||
api.registerUser = function(req, res, next) {
|
||||
var regUname = RegexEscape(req.body.username);
|
||||
var email = req.body.email && req.body.email.toLowerCase();
|
||||
async.auto({
|
||||
validate: function(cb) {
|
||||
if (!(req.body.username && req.body.password && req.body.email))
|
||||
|
|
@ -80,14 +79,14 @@ api.registerUser = function(req, res, next) {
|
|||
cb();
|
||||
},
|
||||
findReg: function(cb) {
|
||||
User.findOne({$or:[{'auth.local.email': email}, {'auth.local.username': regUname}]}, {'auth.local':1}, cb);
|
||||
User.findOne({$or:[{'auth.local.email': req.body.email}, {'auth.local.username': regUname}]}, {'auth.local':1}, cb);
|
||||
},
|
||||
findFacebook: function(cb){
|
||||
User.findOne({_id: req.headers['x-api-user'], apiToken: req.headers['x-api-key']}, {auth:1}, cb);
|
||||
},
|
||||
register: ['validate', 'findReg', 'findFacebook', function(cb, data) {
|
||||
if (data.findReg) {
|
||||
if (email === data.findReg.auth.local.email) return cb({code:401, err:"Email already taken"});
|
||||
if (req.body.email === data.findReg.auth.local.email) return cb({code:401, err:"Email already taken"});
|
||||
if (regUname.test(data.findReg.auth.local.username)) return cb({code:401, err:"Username already taken"});
|
||||
}
|
||||
var salt = utils.makeSalt();
|
||||
|
|
@ -95,7 +94,7 @@ api.registerUser = function(req, res, next) {
|
|||
auth: {
|
||||
local: {
|
||||
username: req.body.username,
|
||||
email: email,
|
||||
email: req.body.email.toLowerCase(),
|
||||
salt: salt,
|
||||
hashed_password: utils.encryptPassword(req.body.password, salt)
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue