mozilla/django-browserid — pull request #182 by Osmose (2013-08-11 02:03:50+00:00)
Title: Add some resiliency against race conditions during user creation.

Flicks has been seeing an issue where users accidentally trigger two
requests to the Verification view, which attempts to authenticate them
twice, simultaneously. This can cause a race condition in the
authentication logic where a user doesn't exist when we check but does
exist when we attempt to create them.

This patch avoids this by catching IntegrityErrors during user creation
and re-fetching the user from the database. If the user still isn't
found, then we re-raise the IntegrityError; there's not much else we can
reasonably do.