From 43ef4e51b527551ab176f5fef5a9caa71d42da43 Mon Sep 17 00:00:00 2001 From: Blade Barringer Date: Sat, 21 Nov 2015 14:56:20 -0600 Subject: [PATCH] fix(model): Remove pre validation from user model --- website/src/models/user.js | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/website/src/models/user.js b/website/src/models/user.js index 2d001a3ca6..0deca34bac 100644 --- a/website/src/models/user.js +++ b/website/src/models/user.js @@ -609,37 +609,6 @@ function _setProfileName (user) { return localUsername || facebookUsername || anonymous; } -schema.pre('validate', function beforeValidateUser (next) { - if (!this.auth.facebook.id || this.auth.local.email || this.auth.local.username) { - if (!this.auth.local.email) { - this.invalidate('auth.local.email', shared.i18n.t('missingEmail')); - return next(); - } - - if (!this.auth.local.username) { - this.invalidate('auth.local.username', shared.i18n.t('missingUsername')); - return next(); - } - } - - // Validate password and password confirmation and create hashed version - if (this.isModified('auth.local.password') || this.isNew() && !this.auth.facebook.id) { // TODO this does not catch when you already have social auth and password isn't passedß - if (!this.auth.local.password) { - this.invalidate('auth.local.password', shared.i18n.t('missingPassword')); - return next(); - } - - if (this.auth.local.password !== this.auth.local.passwordConfirmation) { - this.invalidate('auth.local.passwordConfirmation', shared.i18n.t('passwordConfirmationMatch')); - return next(); - } - - this.hashed_password = passwordUtils.encrypt(this.auth.local.password, this.auth.local.salt); // eslint-disable-line camelcase - } - - next(); -}); - schema.pre('save', function postSaveUser (next) { // Do not store password and passwordConfirmation this.auth.local.password = this.local.auth.passwordConfirmation = undefined;