mirror of
https://github.com/wassname/talk.git
synced 2026-07-11 16:39:49 +08:00
remove logs. missed some errors
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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!');
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user