Users with multiple emails can't join
sobolevn opened this issue · 4 comments
I have the same issue as the person here: jazzband/help#18
I have tried that locally and have figured out, that it is broken in this line: https://github.com/jazzband/website/blob/master/jazzband/models.py#L116
What happens: github
returns a list of emails, if the user has set it this way (I have two, for example). That line raises orm_exc.MultipleResultsFound("Multiple rows were found for one_or_none()")
. What works for me:
def check_verified_emails(self):
return (self.email_addresses.filter_by(verified=True).first()
is not None)
So, there's also an option to remove second email from github
before first login.
I can send PR, if that solution is fine.
D'oh, thanks for looking into this, this is exactly right. I'm still getting used to SQLAlchemy and simply didn't understand the workings of first_or_none
, first
, scalar
etc. The PR looks fine.