diff --git a/client/coral-framework/helpers/response.js b/client/coral-framework/helpers/response.js index 90376f508..e4e6e7c37 100644 --- a/client/coral-framework/helpers/response.js +++ b/client/coral-framework/helpers/response.js @@ -38,7 +38,6 @@ const handleResp = res => { throw new Error('Not Authorized to make this request'); } else if (res.status > 399) { return res.json().then(err => { - console.log(err); let message = err.message || res.status; if (err.error && err.error.translation_key) { message = err.error.translation_key; diff --git a/errors.js b/errors.js index 7e6bbaa63..0651b4fff 100644 --- a/errors.js +++ b/errors.js @@ -23,6 +23,11 @@ const ErrMissingDisplay = new Error('A display name is required to create a user ErrMissingDisplay.translation_key = 'DISPLAY_NAME_REQUIRED'; ErrMissingDisplay.status = 400; +// ErrMissingToken is returned in the event that the password reset is requested +// without a token. +const ErrMissingToken = new Error('token is required'); +ErrMissingToken.status = 400; + // ErrContainsProfanity is returned in the event that the middleware detects // profanity/wordlisted words in the payload. const ErrContainsProfanity = new Error('Suspected profanity. If you think this in error, please let us know!'); diff --git a/routes/api/account/index.js b/routes/api/account/index.js index 6a853e79d..617e79740 100644 --- a/routes/api/account/index.js +++ b/routes/api/account/index.js @@ -3,15 +3,7 @@ const router = express.Router(); const User = require('../../../models/user'); const mailer = require('../../../services/mailer'); const authorization = require('../../../middleware/authorization'); - -// ErrPasswordTooShort is returned when the password length is too short. -const ErrPasswordTooShort = new Error('password must be at least 8 characters'); -ErrPasswordTooShort.status = 400; - -// ErrMissingToken is returned in the event that the password reset is requested -// without a token. -const ErrMissingToken = new Error('token is required'); -ErrMissingToken.status = 400; +const errors = require('../../../errors'); //============================================================================== // ROUTES @@ -31,7 +23,7 @@ router.post('/email/confirm', (req, res, next) => { } = req.body; if (!token) { - return next(ErrMissingToken); + return next(errors.ErrMissingToken); } User @@ -101,11 +93,11 @@ router.put('/password/reset', (req, res, next) => { } = req.body; if (!token) { - return next(ErrMissingToken); + return next(errors.ErrMissingToken); } if (!password || password.length < 8) { - return next(ErrPasswordTooShort); + return next(errors.ErrPasswordTooShort); } User.verifyPasswordResetToken(token) @@ -139,4 +131,3 @@ router.put('/settings', authorization.needed(), (req, res, next) => { }); module.exports = router; -module.exports.ErrPasswordTooShort = ErrPasswordTooShort;