Commit c8ffcfe6 authored by David Seaward's avatar David Seaward

account for existing entries in the user table (eg. after a failed deployment)

parent ba01293a
...@@ -75,7 +75,15 @@ class AuthenticationBackend(BaseBackend): ...@@ -75,7 +75,15 @@ class AuthenticationBackend(BaseBackend):
if self.is_valid_jwt(normalized_username, password): if self.is_valid_jwt(normalized_username, password):
user = user_model(username=username, email=None) # try to get a preexisting user object
# otherwise create a new one
try:
user = user_model.objects.get(username=username)
except user_model.DoesNotExist:
user = user_model(username=username, email=None)
# update/set user details
user.email = user.get_identity() user.email = user.get_identity()
user.set_password(password) user.set_password(password)
user.save() user.save()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment