[WIP] : Move email verification from client to server #4767
Conversation
| uid: req.query.uid | ||
| }; | ||
|
|
||
| let options = req.query.options; |
| const logger = require('mozlog')('server.get-verify-email'); | ||
| const config = require('../configuration'); | ||
|
|
||
| module.exports = function (uid, code, options) { |
vladikoff
Feb 28, 2017
Contributor
uid, code, options arguments here won't be useful. All these come from req below
uid, code, options arguments here won't be useful. All these come from req below
| } | ||
| } | ||
|
|
||
| got.post(config.get('fxaccount_url') + '/v1/recovery_email/verify_code', { |
vladikoff
Feb 28, 2017
Contributor
See if we can use a template literal here: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals instead of +
See if we can use a template literal here: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Template_literals instead of +
3f65da8
to
1de6fc7
| path: '/verify_email/', | ||
| process: function (req, res, next) { | ||
| req.url = '/'; | ||
| console.log('items', req.query); |
vladikoff
Feb 28, 2017
Contributor
no need for this console log
no need for this console log
|
|
||
| let data = { | ||
| code: req.query.code, | ||
| uid: req.query.uid |
vladikoff
Feb 28, 2017
•
Contributor
@divyabiyani we need to add validation to make sure these 2 items are present in the query request. If they are not then do not make the request below. You need a simpler version of this example:
use the joi module to validate the structure of uid and code. See the format of those 2 fields here: https://github.com/mozilla/fxa-auth-server/blob/7226ce0f627a0510ed93d8056663b1d6c7f42702/docs/api.md#post-v1recovery_emailverify_code
@divyabiyani we need to add validation to make sure these 2 items are present in the query request. If they are not then do not make the request below. You need a simpler version of this example:
use the joi module to validate the structure of uid and code. See the format of those 2 fields here: https://github.com/mozilla/fxa-auth-server/blob/7226ce0f627a0510ed93d8056663b1d6c7f42702/docs/api.md#post-v1recovery_emailverify_code
vladikoff
Feb 28, 2017
Contributor
✅ we need tests for this validation
| data.reminder = req.query.reminder; | ||
| } | ||
|
|
||
| const fxaAccountUrl = config.get('fxaccount_url'); |
vladikoff
Feb 28, 2017
Contributor
Move this section above +module.exports = function () {.
This way you are not gonna be calling config.get on every request.
Move this section above +module.exports = function () {.
This way you are not gonna be calling config.get on every request.
| got.post(`${fxaAccountUrl}/v1/recovery_email/verify_code`, { | ||
| body: data | ||
| }).then(function (res) { | ||
| // verified, all good |
vladikoff
Feb 28, 2017
Contributor
✅ need tests for success case
| // verified, all good | ||
| next(); | ||
| }).catch(function (err) { | ||
| // something went wrong.... |
vladikoff
Feb 28, 2017
Contributor
✅ need tests for error case
|
|
||
| joi.validate(data, BODY_SCHEMA, function (err, value) { | ||
| if (err) { | ||
| logger.error(err); |
vladikoff
Mar 1, 2017
Contributor
@divyabiyani in a case of an error it seems like next(); will never be called and the request will hang forever
@divyabiyani in a case of an error it seems like next(); will never be called and the request will hang forever
vladikoff
Mar 1, 2017
Contributor
you can check this if you navigate to http://127.0.0.1:3030/verify_email without any query params
you can check this if you navigate to http://127.0.0.1:3030/verify_email without any query params
e7bd350
to
95dd217
|
@divyabiyani fixes for call count tests: https://gist.github.com/vladikoff/9925b07a96c8fef538dee6cd0bc9bae0 See if this useful: https://github.com/mozilla/fxa-content-server/blob/master/tests/server/metrics-unit.js#L182 |
|
Continued in #4794 |
Fixes #4482.