* Regression test #1649

* Address comments

* Comment

* Change emails to help debug flaky test failures

* More logging info to debug flaky tests
This commit is contained in:
Drew
2016-05-25 16:48:18 -07:00
committed by Florent Vilmart
parent 98f8db36e8
commit 0850c184d3
2 changed files with 77 additions and 22 deletions

View File

@@ -1,7 +1,7 @@
// These methods handle the User-related routes.
import deepcopy from 'deepcopy';
import Config from '../Config';
import ClassesRouter from './ClassesRouter';
import PromiseRouter from '../PromiseRouter';
import rest from '../rest';
@@ -156,19 +156,36 @@ export class UsersRouter extends ClassesRouter {
}
handleResetRequest(req) {
let { email } = req.body;
if (!email) {
throw new Parse.Error(Parse.Error.EMAIL_MISSING, "you must provide an email");
}
let userController = req.config.userController;
return userController.sendPasswordResetEmail(email).then((token) => {
return Promise.resolve({
response: {}
});
}, (err) => {
throw new Parse.Error(Parse.Error.EMAIL_NOT_FOUND, `no user found with email ${email}`);
});
try {
Config.validateEmailConfiguration({
verifyUserEmails: true, //A bit of a hack, as this isn't the intended purpose of this parameter
appName: req.config.appName,
publicServerURL: req.config.publicServerURL,
});
} catch (e) {
if (typeof e === 'string') {
// Maybe we need a Bad Configuration error, but the SDKs won't understand it. For now, Internal Server Error.
throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'An appName, publicServerURL, and emailAdapter are required for password reset functionality.');
} else {
throw e;
}
}
let { email } = req.body;
if (!email) {
throw new Parse.Error(Parse.Error.EMAIL_MISSING, "you must provide an email");
}
let userController = req.config.userController;
return userController.sendPasswordResetEmail(email).then(token => {
return Promise.resolve({
response: {}
});
}, err => {
if (err.code === Parse.Error.OBJECT_NOT_FOUND) {
throw new Parse.Error(Parse.Error.EMAIL_NOT_FOUND, `No user found with email ${email}.`);
} else {
throw err;
}
});
}