From 412fddd0655f66e6b6684d78ea47c41fcb07a314 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Sat, 23 Dec 2017 16:04:12 -0800 Subject: [PATCH] fix(models/User): Remove dup before create --- common/models/user.js | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/common/models/user.js b/common/models/user.js index a800345e92..a7a0863c62 100644 --- a/common/models/user.js +++ b/common/models/user.js @@ -295,37 +295,6 @@ module.exports = function(User) { return ctx.res.redirect(redirect); }); - User.beforeRemote('create', function({ req, res }, _, next) { - req.body.username = 'fcc' + uuid.v4().slice(0, 8); - if (!req.body.email) { - return next(); - } - if (!isEmail(req.body.email)) { - return next(new Error('Email format is not valid')); - } - return User.doesExist(null, req.body.email) - .then(exists => { - if (!exists) { - return next(); - } - - req.flash('error', { - msg: dedent` - The ${req.body.email} email address is already associated with an account. - Try signing in with it here instead. - ` - }); - - return res.redirect('/email-signin'); - }) - .catch(err => { - console.error(err); - req.flash('error', { - msg: 'Oops, something went wrong, please try again later' - }); - return res.redirect('/email-signin'); - }); - }); User.beforeRemote('login', function(ctx, notUsed, next) { const { body } = ctx.req;