[Fix bug 1111549] Handle race condition on user authentication.

Code based on:
https://github.com/mozilla/django-browserid/commit/357aa7933fcba7393b3b68eae721ff64dc72e2d8
This is causing a circular dependency that's why ``IntegrityError`` is imported here.