-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameter validation for /account/password/confirmReset #515 #516
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
0fb0850
add redirect if either param is missing - working on flash
beckpaul f639adc
refactor to be more funcitonal - flashes are harder than ancicipated
beckpaul 62dc98a
add .tool-versions to git ignore - this is used by asdf
beckpaul 0bcd4c7
less verbose - turnary was being problematic
beckpaul 0c1f04b
flashes work with this - however it does not confirm to other standards
beckpaul 90497eb
found an example of this - working flashes following existing code co…
beckpaul ce71bd8
safe flash
beckpaul 0d33d8b
fix flash persistence
beckpaul f1ef63c
linting
beckpaul 64fe9fe
update unit tests
beckpaul 6e186cc
lint again - sorry for wasting minutes my bad
beckpaul 22cae7d
fix up testing
beckpaul 2de4075
refactor to use express-validation
beckpaul e2adad7
lint
beckpaul 91b1785
fix uppercase u
beckpaul 4e5872f
user express validatior in routes for query params
beckpaul 4065a4b
update tests, add secondary test
beckpaul 4aba28d
add logging to docker - prints console.log into docker logs since the…
beckpaul 02ccdee
merge
beckpaul 27e2ad8
merge
beckpaul d60bf70
merge
beckpaul 4959061
use new linting methodology - refactors
beckpaul 2514fa6
comments and append to error for clarity
beckpaul fc0e862
organize setup a bit - fix tests
beckpaul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this still needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will check and remove in next pr if not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already removed it, so you need to add it again... sry :)