-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add redirect if either param is missing - working on flash * refactor to be more funcitonal - flashes are harder than ancicipated * add .tool-versions to git ignore - this is used by asdf * less verbose - turnary was being problematic * flashes work with this - however it does not confirm to other standards * found an example of this - working flashes following existing code conventions * safe flash * fix flash persistence * linting * update unit tests * lint again - sorry for wasting minutes my bad * fix up testing * refactor to use express-validation * lint * fix uppercase u * user express validatior in routes for query params * update tests, add secondary test * add logging to docker - prints console.log into docker logs since they dont seem to be forwarded to the browser * merge * merge * merge * use new linting methodology - refactors * comments and append to error for clarity * organize setup a bit - fix tests
- Loading branch information
Showing
9 changed files
with
86 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,3 +52,4 @@ public/js/*.js | |
sessions | ||
|
||
dist | ||
.tool-versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 47 additions & 10 deletions
57
src/backend/routes/views/account/get/confirmPasswordReset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,53 @@ | ||
const axios = require('axios') | ||
const appConfig = require('../../../../config/app') | ||
const { validationResult } = require('express-validator') | ||
exports = module.exports = function (req, res) { | ||
const locals = res.locals | ||
const errors = validationResult(req) | ||
|
||
// locals.section is used to set the currently selected | ||
// item in the header navigation. | ||
locals.section = 'account' | ||
// A render/redirect ignores this if not async and renders the confirm | ||
// Theres probably a better way to do this | ||
if (!errors.isEmpty()) { | ||
return renderRequestPasswordReset(req, res, errors) | ||
} | ||
|
||
locals.formData = req.body || {} | ||
res.render('account/confirmPasswordReset', { | ||
section: 'account', | ||
formData: req.body || {}, | ||
username: req.query.username, | ||
token: req.query.token | ||
}) | ||
} | ||
|
||
const renderRequestPasswordReset = async (req, res, errors) => { | ||
axios.post(appConfig.apiUrl + '/users/buildSteamPasswordResetUrl', {}, { maxRedirects: 0 }).then(response => { | ||
if (response.status !== 200) { | ||
throw new Error('java-api error') | ||
} | ||
|
||
const flash = null | ||
errors.errors[errors.errors.length - 1].msg += '. You may request a new link here' | ||
|
||
// Render the view | ||
locals.username = req.query.username | ||
locals.token = req.query.token | ||
res.render('account/confirmPasswordReset', { flash }) | ||
return res.render('account/requestPasswordReset', { | ||
section: 'account', | ||
errors: { | ||
class: 'alert-danger', | ||
messages: errors, | ||
type: 'Error!' | ||
}, | ||
steamReset: response.data.steamUrl, | ||
formData: {}, | ||
recaptchaSiteKey: appConfig.recaptchaKey | ||
}) | ||
}).catch(error => { | ||
console.error(error.toString()) | ||
return res.render('account/requestPasswordReset', { | ||
section: 'account', | ||
errors: { | ||
class: 'alert-danger', | ||
messages: error.toString(), | ||
type: 'Error!' | ||
}, | ||
formData: {}, | ||
recaptchaSiteKey: appConfig.recaptchaKey | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters