Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Allow password providers to bind emails #4947

Merged
merged 4 commits into from
Mar 28, 2019
Merged

Conversation

anoadragon453
Copy link
Member

This PR allows password provider modules to bind email addresses when a user is registering and is motivated by matrix-org/matrix-synapse-ldap3#58

@anoadragon453 anoadragon453 requested a review from a team March 26, 2019 18:13
@codecov
Copy link

codecov bot commented Mar 26, 2019

Codecov Report

Merging #4947 into develop will decrease coverage by <.01%.
The diff coverage is 40%.

@@             Coverage Diff             @@
##           develop    #4947      +/-   ##
===========================================
- Coverage    60.43%   60.43%   -0.01%     
===========================================
  Files          328      328              
  Lines        34093    34097       +4     
  Branches      5627     5628       +1     
===========================================
+ Hits         20605    20606       +1     
- Misses       12017    12019       +2     
- Partials      1471     1472       +1

threepid_dict = {
"medium": "email",
"address": email,
"validated_at": self.hs.get_clock().time_msec(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are ignoring the validated_at param

}

# Bind email to new account
yield self._register_email_threepid(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the record: where you have a function which just does some synchronous things and ends up calling an asynchronous function, you can skip @inlineCallbacks and just return the deferred from the other function:

def bind_email_to_account():
    do_synchronous_stuff()
    return self._register_email_threepid(...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know, thanks!

@@ -406,6 +412,32 @@ def register_email(self, threepidCreds):
403, "Third party identifier is not allowed"
)

@defer.inlineCallbacks
def bind_email_to_account(self, user_id, email, validated_at=None):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless you have a reason for factoring this out, i feel like it may as well be inlined.

@anoadragon453 anoadragon453 requested review from richvdh and a team March 27, 2019 11:14
Copy link
Member

@richvdh richvdh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@anoadragon453 anoadragon453 merged commit 7a91b9d into develop Mar 28, 2019
@anoadragon453 anoadragon453 deleted the anoa/3pid_email_binding branch March 28, 2019 15:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants