Skip to content

Commit

Permalink
Merge pull request #100 from mwayne/bug/invitations-case-sensitive-email
Browse files Browse the repository at this point in the history
Ignore email case when accepting invites after signup
  • Loading branch information
bee-keeper committed Feb 23, 2018
2 parents 39c10b8 + 4cc21e3 commit 22f9701
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion invitations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def accept_invitation(invitation, request, signal_sender):


def accept_invite_after_signup(sender, request, user, **kwargs):
invitation = Invitation.objects.filter(email=user.email).first()
invitation = Invitation.objects.filter(email__iexact=user.email).first()
if invitation:
accept_invitation(invitation=invitation,
request=request,
Expand Down
28 changes: 28 additions & 0 deletions tests/allauth/test_allauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,34 @@ def test_accept_invite_accepted_invitation_after_signup(
invite = Invitation.objects.get(email='email@example.com')
assert invite.accepted is True

@pytest.mark.parametrize('method', [
('get'),
('post'),
])
def test_invite_accepted_after_signup_with_altered_case_email(
self, settings, method, sent_invitation_by_user_a, user_a):
settings.INVITATIONS_ACCEPT_INVITE_AFTER_SIGNUP = True
client_with_method = getattr(self.client, method)
resp = client_with_method(
reverse('invitations:accept-invite',
kwargs={'key': sent_invitation_by_user_a.key}
), follow=True)

invite = Invitation.objects.get(email='email@example.com')
assert invite.accepted is False
form = resp.context_data['form']
assert 'email@example.com' == form.fields['email'].initial

resp = self.client.post(
reverse('account_signup'),
{'email': 'EMAIL@EXAMPLE.COM',
'username': 'username',
'password1': 'password',
'password2': 'password'
})
invite = Invitation.objects.get(email='email@example.com')
assert invite.accepted is True


class TestAllAuthIntegration:
client = Client()
Expand Down

0 comments on commit 22f9701

Please sign in to comment.