Add blacklist checks for API UserID

This commit is contained in:
2010-10-28 09:57:06 +01:00
parent 6cc34a9c05
commit b48b81ed7a
2 changed files with 7 additions and 1 deletions

View File

@@ -42,6 +42,7 @@ BLACKLIST_TYPE_CORPORATION = 2
BLACKLIST_TYPE_ALLIANCE = 3
BLACKLIST_TYPE_EMAIL = 4
BLACKLIST_TYPE_AUTH = 5
BLACKLIST_TYPE_APIUSERID = 6
BLACKLIST_TYPE_CHOICES = (
(BLACKLIST_TYPE_REDDIT, 'Reddit Account'),
@@ -50,6 +51,7 @@ BLACKLIST_TYPE_CHOICES = (
(BLACKLIST_TYPE_ALLIANCE, 'Alliance'),
(BLACKLIST_TYPE_EMAIL, 'Email Address'),
(BLACKLIST_TYPE_AUTH, 'Auth Account'),
(BLACKLIST_TYPE_APIUSERID, 'EVE API User ID'),
)
BLACKLIST_SOURCE_INTERNAL = 0

View File

@@ -59,10 +59,14 @@ class Application(models.Model):
# Check Alliance blacklists
alliances = [a[0].lower() for a in evechars.values_list('corporation__alliance__name') if a and a[0]]
objs = bl_items.filter(type=BLACKLIST_TYPE_ALLIANCE, value__in=alliances)
blacklist.extend(objs)
# Check API Key blacklists
keys = self.user.eveaccount_set.all().values_list('api_user_id', flat=True)
objs = bl_items.filter(type=BLACKLIST_TYPE_APIUSERID, value__in=keys)
blacklist.extend(objs)
return blacklist
def save(self, *args, **kwargs):