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

Neilj/fix threepid auth check #4435

Merged
merged 2 commits into from
Jan 24, 2019
Merged

Conversation

neilisfragile
Copy link
Contributor

If mau_limits_reserved_threepids is populated but the threepid to test is None the method will barf. This PRs adds a guard to prevent this.

@neilisfragile neilisfragile changed the base branch from master to develop January 22, 2019 16:54
@codecov-io
Copy link

Codecov Report

Merging #4435 into develop will decrease coverage by <.01%.
The diff coverage is 85.71%.

@@            Coverage Diff             @@
##           develop   #4435      +/-   ##
==========================================
- Coverage     73.7%   73.7%   -0.01%     
==========================================
  Files          300     300              
  Lines        29705   29707       +2     
  Branches      4882    4883       +1     
==========================================
+ Hits         21895   21896       +1     
+ Misses        6385    6382       -3     
- Partials      1425    1429       +4

@neilisfragile neilisfragile requested a review from a team January 22, 2019 17:23
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.

I note that one of the two callsites already has a None-guard, and I have to say I wonder if we shouldn't be adding a guard to the other, rather than adding the guard to is_threepid_reserved, which makes the behaviour of the latter a bit weird.

I could live with doing it your way, but if you're going to do it, please can you update the docstring on is_threepid_reserved to document the behaviour when threepid is None.

"""Check the threepid against the reserved threepid config
Args:
config(ServerConfig) - to access server config attributes
reserved_threepids([dict]) - list of reserved threepids
threepid(dict) - The threepid to test for
Copy link
Member

Choose a reason for hiding this comment

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

evidently this can also be not a dict?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay have moved the guard out of the method.

@richvdh richvdh self-requested a review January 24, 2019 11:11
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

@@ -416,8 +416,11 @@ def on_POST(self, request):
)
# Necessary due to auth checks prior to the threepid being
# written to the db
if is_threepid_reserved(self.hs.config, threepid):
yield self.store.upsert_monthly_active_user(registered_user_id)
if 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 future ref: I'd be inclined to merge these into one if statement, to reduce indentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah I was in two minds - I tried it on one line but it seemed less readable which I why I went with the indent. Noted for future

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.

3 participants