Skip to content

Commit

Permalink
Merge pull request #571 from rdmorganiser/fix_invite
Browse files Browse the repository at this point in the history
Fix member invite for non unique user email
  • Loading branch information
jochenklar committed Jan 21, 2023
2 parents 6e30879 + 37f78de commit 66bfdbf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions rdmo/projects/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,16 +192,17 @@ def __init__(self, *args, **kwargs):

def clean_username_or_email(self):
username_or_email = self.cleaned_data['username_or_email']
usermodel = get_user_model()

# check if it is a registered
# check if it is a registered user
try:
self.cleaned_data['user'] = get_user_model().objects.get(Q(username=username_or_email) | Q(email__iexact=username_or_email))
self.cleaned_data['user'] = usermodel.objects.get(Q(username=username_or_email) | Q(email__iexact=username_or_email))
self.cleaned_data['email'] = self.cleaned_data['user'].email

if self.cleaned_data['user'] in self.project.user.all():
raise ValidationError(_('The user is already a member of the project.'))

except get_user_model().DoesNotExist:
except (usermodel.DoesNotExist, usermodel.MultipleObjectsReturned):
if settings.PROJECT_SEND_INVITE:
# check if it is a valid email address, this will raise the correct ValidationError
EmailValidator()(username_or_email)
Expand Down

0 comments on commit 66bfdbf

Please sign in to comment.