mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 13:17:24 +01:00
mock for emailer for resetPassword route
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../../helpers/api-integration/v3';
|
||||
} from '../../../../helpers/api-integration/v3';
|
||||
|
||||
describe('POST /user/reset-password', async () => {
|
||||
let endpoint = '/user/reset-password';
|
||||
@@ -11,21 +11,19 @@ describe('POST /user/reset-password', async () => {
|
||||
user = await generateUser();
|
||||
});
|
||||
|
||||
/*
|
||||
it('resets password', async () => {
|
||||
let response = await user.post(endpoint, {
|
||||
email: user.auth.local.email,
|
||||
});
|
||||
expect(response).to.eql({code: 200, message: t('passwordReset')});
|
||||
expect(response).to.eql({ message: t('passwordReset') });
|
||||
});
|
||||
|
||||
it('same message on error as on success', async () => {
|
||||
let response = await user.post(endpoint, {
|
||||
email: 'nonExistent@email.com',
|
||||
});
|
||||
expect(response).to.eql({code: 200, message: t('passwordReset')});
|
||||
expect(response).to.eql({ message: t('passwordReset') });
|
||||
});
|
||||
*/
|
||||
|
||||
it('errors if email is not provided', async () => {
|
||||
await expect(user.post(endpoint)).to.eventually.be.rejected.and.eql({
|
||||
@@ -96,6 +96,9 @@ api.resetPassword = {
|
||||
middlewares: [],
|
||||
url: '/user/reset-password',
|
||||
async handler (req, res) {
|
||||
|
||||
console.log('is prod is:', nconf.get('IS_PROD'));
|
||||
|
||||
req.checkBody({
|
||||
email: {
|
||||
notEmpty: {errorMessage: res.t('missingEmail')},
|
||||
|
||||
@@ -25,9 +25,13 @@ let smtpTransporter = createTransport({
|
||||
// Send email directly from the server using the smtpTransporter,
|
||||
// used only to send password reset emails because users unsubscribed on Mandrill wouldn't get them
|
||||
export function send (mailData) {
|
||||
return smtpTransporter
|
||||
.sendMail(mailData)
|
||||
.catch((error) => logger.error(error));
|
||||
if (IS_PROD) {
|
||||
return smtpTransporter
|
||||
.sendMail(mailData)
|
||||
.catch((error) => logger.error(error));
|
||||
} else {
|
||||
return { send: () => {} } // mock
|
||||
}
|
||||
}
|
||||
|
||||
export function getUserInfo (user, fields = []) {
|
||||
|
||||
Reference in New Issue
Block a user