Skip to content
This repository has been archived by the owner. It is now read-only.

fix(email): Add ability for content server to delegate sending emails #4155

Merged
merged 3 commits into from Sep 20, 2016

Conversation

@vbudhram
Copy link
Contributor

@vbudhram vbudhram commented Sep 15, 2016

Fixes #4105


if (! account.get('verified') && isSignUp) {
// Only send account verification email, it signing up

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Sep 16, 2016
Member

it signing => if signing

beforeEach(function () {
account = user.initAccount({ email: 'email', uid: 'uid' });
// Ensure that content-server can correctly handle any emailSent response
var emailSentTestCases = [{

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Sep 16, 2016
Member

Can you use const instead of var here? We're living in the (mostly) present in the content server!

} else if (property === 'verificationReason') {
return VerificationReasons.SIGN_UP;
}
sinon.stub(account, 'get', function (property) {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Sep 16, 2016
Member

Is there a reason to use a stub and not a simple set on the account?

account.set({
  emailSent: testCase.emailSent,
  verificationReason: VerificationReasons.SIGN_UP,
  verified: false
});

I don't see the stub checked for whether it's called, so I'm not sure overriding it provides any value.

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Sep 16, 2016
Member

It seems like in your account.signIn stub, you should set these values to mimic real life.

@@ -360,8 +360,11 @@ define(function (require, exports, module) {
.then(function () {
var isSignUp =
account.get('verificationReason') === VerificationReasons.SIGN_UP;
var emailSent = !! account.get('emailSent');

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Sep 16, 2016
Member

Might as well const these two variables too.

if (! account.get('verified') && isSignUp) {
// Only send account verification email, it signing up
// and a verification email has not been sent by auth-server.
if (! account.get('verified') && isSignUp && ! emailSent) {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Sep 16, 2016
Member

Are you going to send the sendEmailIfUnverified directly from the fxa-js-client? It'd probably be best to only use the fxa-js-client as a pipe that transfers sendEmailIfUnverified from the fxa-js-client consumer to the auth server to avoid making an assumption about who is consuming the client, we don't want to inadvertently break anyone.

This comment has been minimized.

@vbudhram

vbudhram Sep 16, 2016
Author Contributor

That was my original plan, but decided against it for that reason, the js-client sets the default of sendEmailIfUnverified=false if it is not passed. Will update so that value gets propagated to client.


sinon.spy(notifier, 'triggerRemote');
sinon.stub(user, 'setSignedInAccount', function () {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Sep 16, 2016
Member

Is it possible to use a spy instead of a stub here? setSignedInAccount doesn't seem like it has any side effects that should cause problems elsewhere.

if (! account.get('verified') && isSignUp) {
// Only send account verification email, it signing up
// and a verification email has not been sent by auth-server.
if (! account.get('verified') && isSignUp && ! emailSent) {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Sep 16, 2016
Member

Can you update the comment that once we are reasonably sure all consumers delegate email sending to the auth-server, this branch can be removed?

Copy link
Member

@shane-tomlinson shane-tomlinson left a comment

This PR looks a lot like what I hacked together to test, which is good! Most of the comments are minor nits. The one major change I'd make is to have fxa-client.signIn send the new query parameter the fxa-js-client.signIn to avoid making assumptions about who is consuming the fxa-js-client as well as prevent spreading that branching knowledge around too much.

Thanks @vbudhram!

} else if (property === 'verificationReason') {
return VerificationReasons.SIGN_UP;
}
sinon.stub(account, 'get', function (property) {

This comment has been minimized.

@shane-tomlinson

shane-tomlinson Sep 16, 2016
Member

It seems like in your account.signIn stub, you should set these values to mimic real life.

@vbudhram
Copy link
Contributor Author

@vbudhram vbudhram commented Sep 19, 2016

@shane-tomlinson Updated from review, sending back to you!

@shane-tomlinson
Copy link
Member

@shane-tomlinson shane-tomlinson commented Sep 20, 2016

LGTM, once the fxa-js-client merges and we can run the full functional test suite, let's test and merge!

@vladikoff
Copy link
Contributor

@vladikoff vladikoff commented Sep 20, 2016

Needs a new fxa-js-client

@vladikoff vladikoff merged commit b7a0963 into master Sep 20, 2016
4 checks passed
4 checks passed
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 97.464%
Details
@vladikoff vladikoff deleted the issue-4105-delgate-email-sending branch Sep 20, 2016
@vbudhram
Copy link
Contributor Author

@vbudhram vbudhram commented Sep 20, 2016

Thanks! @shane-tomlinson @vladikoff

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants