Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: user email integrity error #861

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions backend/app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ def clean(self):
raise err


class CustomSignupForm(SignupForm):
def clean_email(self):
email = self.cleaned_data.get('email')
if email and User.objects.filter(email__iexact=email).exists():
raise forms.ValidationError("A user with that email already exists.")
return email


class RecaptchaSignupForm(SignupForm):
recaptcha_token = CharField(required=True)

Expand Down
4 changes: 3 additions & 1 deletion backend/app/views/web_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
from lib.view_helpers import get_print_or_404, get_printer_or_404, get_paginator, get_template_path

from app.models import (User, Printer, SharedResource, GCodeFile, NotificationSetting)
from app.forms import SocialAccountAwareLoginForm
from app.forms import SocialAccountAwareLoginForm, CustomSignupForm
from lib import channels
from lib.file_storage import save_file_obj
from app.tasks import preprocess_timelapse
Expand All @@ -47,6 +47,8 @@ class SocialAccountAwareLoginView(LoginView):
form_class = SocialAccountAwareLoginForm

class SocialAccountAwareSignupView(SignupView):
form_class = CustomSignupForm

def dispatch(self, request, *args, **kwargs):
if settings.ACCOUNT_ALLOW_SIGN_UP:
return super().dispatch(request, *args, **kwargs)
Expand Down
Loading