1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-01 16:51:11 +03:00

Fix an issue reauthing as a social auth user

If a social auth user is deleted and then attemnpts to relogin after the
old user object has been removed then it can cause an error.  So here
we'll add an extra lookup for the user just to verify
This commit is contained in:
Matthew Jones 2015-11-17 12:41:18 -05:00
parent 4fa06bacd8
commit 564f9e2c58

View File

@ -5,7 +5,7 @@ import logging
import threading
import uuid
from django.contrib.auth.models import User
from django.contrib.auth.models import User, AnonymousUser
from django.db.models.signals import post_save
from django.db import IntegrityError
from django.http import HttpResponseRedirect
@ -62,7 +62,12 @@ class ActivityStreamMiddleware(threading.local):
def set_actor(self, user, sender, instance, **kwargs):
if sender == ActivityStream:
if isinstance(user, User) and instance.actor is None:
instance.actor = user
user = User.objects.filter(id=user.id)
if user.exists():
user = user[0]
instance.actor = user
else:
instance.actor = AnonymouseUser
instance.save(update_fields=['actor'])
else:
if instance.id not in self.instance_ids: