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

Error when trying to register with an email address that is already used #177

Closed
cdriehuys opened this issue Aug 17, 2017 · 1 comment
Closed

Comments

@cdriehuys
Copy link
Member

Bug Report

Expected Behavior

When signing up with an email address that has already been used, I expect to get an error stating that the email has been used.

Actual Behavior

A 500 server error occurs with the following traceback:

IntegrityError: duplicate key value violates unique constraint "account_user_email_key"
DETAIL:  Key (email)=(chathan@knowmetools.com) already exists.

  File "django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
IntegrityError: duplicate key value violates unique constraint "account_user_email_key"
DETAIL:  Key (email)=(chathan@knowmetools.com) already exists.

  File "django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "django/views/decorators/csrf.py", line 58, in wrapped_view
    return view_func(*args, **kwargs)
  File "django/views/generic/base.py", line 68, in view
    return self.dispatch(request, *args, **kwargs)
  File "rest_framework/views.py", line 489, in dispatch
    response = self.handle_exception(exc)
  File "rest_framework/views.py", line 449, in handle_exception
    self.raise_uncaught_exception(exc)
  File "rest_framework/views.py", line 486, in dispatch
    response = handler(request, *args, **kwargs)
  File "rest_framework/generics.py", line 192, in post
    return self.create(request, *args, **kwargs)
  File "rest_framework/mixins.py", line 21, in create
    self.perform_create(serializer)
  File "rest_framework/mixins.py", line 26, in perform_create
    serializer.save()
  File "rest_framework/serializers.py", line 215, in save
    self.instance = self.create(validated_data)
  File "km_auth/serializers.py", line 133, in create
    user = User.objects.create_user(**validated_data)
  File "account/managers.py", line 150, in create_user
    user.save()
  File "django/contrib/auth/base_user.py", line 80, in save
    super(AbstractBaseUser, self).save(*args, **kwargs)
  File "django/db/models/base.py", line 807, in save
    force_update=force_update, update_fields=update_fields)
  File "django/db/models/base.py", line 837, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "django/db/models/base.py", line 923, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "django/db/models/base.py", line 962, in _do_insert
    using=using, raw=raw)
  File "django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "django/db/models/query.py", line 1076, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "django/db/models/sql/compiler.py", line 1099, in execute_sql
    cursor.execute(sql, params)
  File "raven/contrib/django/client.py", line 114, in execute
    return real_execute(self, sql, params)
  File "django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
@cdriehuys
Copy link
Member Author

I believe the root cause of this is that we have been assuming email addresses will be unique. We are now seeing that this is true only for verified email addresses.

cdriehuys added a commit that referenced this issue Aug 30, 2017
Email addresses can be duplicated as long as that email has not yet been
verified.

Fixes #177
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant