diff --git a/src/routes/account.js b/src/routes/account.js index 3f8f65f1..bff830fa 100644 --- a/src/routes/account.js +++ b/src/routes/account.js @@ -153,11 +153,11 @@ router.get('/logout', async (_request, response) => { router.get('/forgot-password', async (request, response) => { const renderData = { - input: request.cookies.input, - success_message: request.cookies.success_message, - error_message: request.cookies.error_message, + input: request.cookies.input, + success_message: request.cookies.success_message, + error_message: request.cookies.error_message, } - + response.clearCookie('input', { domain: '.pretendo.network' }); response.render('account/forgot-password', renderData); @@ -169,19 +169,19 @@ router.post('/forgot-password', async (request, response) => { response.cookie('input', input, { domain: '.pretendo.network' }); try { - await util.forgotPassword({ - input, - hCaptchaResponse - }) - - response.clearCookie('input', { domain: '.pretendo.network' }); - - response.cookie('success_message', 'An email has been sent.', { domain: '.pretendo.network' }); - - response.redirect(request.redirect || '/account/forgot-password'); + await util.forgotPassword({ + input, + hCaptchaResponse + }) + + response.clearCookie('input', { domain: '.pretendo.network' }); + + response.cookie('success_message', 'An email has been sent.', { domain: '.pretendo.network' }); + + response.redirect(request.redirect || '/account/forgot-password'); } catch (error) { - response.cookie('error_message', error.message, { domain: '.pretendo.network' }); - return response.redirect('/account/forgot-password'); + response.cookie('error_message', error.message, { domain: '.pretendo.network' }); + return response.redirect('/account/forgot-password'); } }); diff --git a/src/util.js b/src/util.js index 8db00209..00593112 100644 --- a/src/util.js +++ b/src/util.js @@ -132,11 +132,11 @@ async function login(username, password) { async function forgotPassword(forgotPasswordData) { const apiResponse = await apiPostRequest('/v1/forgot-password', {}, forgotPasswordData); - + if (apiResponse.statusCode !== 200) { - throw new Error(apiResponse.body.error); + throw new Error(apiResponse.body.error); } - + return apiResponse.body; } diff --git a/views/account/forgot-password.handlebars b/views/account/forgot-password.handlebars index 6d778b32..101a6d75 100644 --- a/views/account/forgot-password.handlebars +++ b/views/account/forgot-password.handlebars @@ -15,7 +15,7 @@ -
+