mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-17 19:59:29 +00:00
Handle Expired API keys correctly
This commit is contained in:
@@ -7,6 +7,8 @@ API_STATUS_OK = 1
|
|||||||
API_STATUS_AUTH_ERROR = 2
|
API_STATUS_AUTH_ERROR = 2
|
||||||
API_STATUS_OTHER_ERROR = 3
|
API_STATUS_OTHER_ERROR = 3
|
||||||
API_STATUS_ACC_EXPIRED = 4
|
API_STATUS_ACC_EXPIRED = 4
|
||||||
|
API_STATUS_KEY_EXPIRED = 5
|
||||||
|
|
||||||
# This tuple is used to assemble the choices list for the field.
|
# This tuple is used to assemble the choices list for the field.
|
||||||
API_STATUS_CHOICES = (
|
API_STATUS_CHOICES = (
|
||||||
(API_STATUS_PENDING, 'Unknown'),
|
(API_STATUS_PENDING, 'Unknown'),
|
||||||
@@ -14,6 +16,7 @@ API_STATUS_CHOICES = (
|
|||||||
(API_STATUS_AUTH_ERROR, 'Auth Error'),
|
(API_STATUS_AUTH_ERROR, 'Auth Error'),
|
||||||
(API_STATUS_OTHER_ERROR, 'Other Error'),
|
(API_STATUS_OTHER_ERROR, 'Other Error'),
|
||||||
(API_STATUS_ACC_EXPIRED, 'Account Expired'),
|
(API_STATUS_ACC_EXPIRED, 'Account Expired'),
|
||||||
|
(API_STATUS_KEY_EXPIRED, 'Key Expired'),
|
||||||
)
|
)
|
||||||
|
|
||||||
API_KEYTYPE_UNKNOWN = 0
|
API_KEYTYPE_UNKNOWN = 0
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ def queue_apikey_updates(update_delay=86400, batch_size=50):
|
|||||||
log.info("Updating APIs older than %s" % (datetime.now() - delta))
|
log.info("Updating APIs older than %s" % (datetime.now() - delta))
|
||||||
|
|
||||||
if gargoyle.is_active('eve-cak'):
|
if gargoyle.is_active('eve-cak'):
|
||||||
accounts = EVEAccount.objects.filter(api_last_updated__lt=(datetime.now() - delta)).exclude(api_status=API_STATUS_ACC_EXPIRED).exclude(api_status=API_STATUS_AUTH_ERROR).order_by('api_last_updated')[:batch_size]
|
accounts = EVEAccount.objects.filter(api_last_updated__lt=(datetime.now() - delta)).exclude(api_status__in=[API_STATUS_ACC_EXPIRED, API_STATUS_KEY_EXPIRED, API_STATUS_AUTH_ERROR]).order_by('api_last_updated')[:batch_size]
|
||||||
else:
|
else:
|
||||||
accounts = EVEAccount.objects.filter(api_last_updated__lt=(datetime.now() - delta)).exclude(api_status=API_STATUS_ACC_EXPIRED).exclude(api_status=API_STATUS_AUTH_ERROR).exclude(api_keytype__gt=2).order_by('api_last_updated')[:batch_size]
|
accounts = EVEAccount.objects.filter(api_last_updated__lt=(datetime.now() - delta)).exclude(api_status__in=[API_STATUS_ACC_EXPIRED, API_STATUS_KEY_EXPIRED, API_STATUS_AUTH_ERROR]).exclude(api_keytype__gt=2).order_by('api_last_updated')[:batch_size]
|
||||||
log.info("%s account(s) to update" % accounts.count())
|
log.info("%s account(s) to update" % accounts.count())
|
||||||
for acc in accounts:
|
for acc in accounts:
|
||||||
log.debug("Queueing UserID %s for update" % acc.pk)
|
log.debug("Queueing UserID %s for update" % acc.pk)
|
||||||
@@ -145,6 +145,8 @@ def import_apikey_func(api_userid, api_key, user=None, force_cache=False, log=lo
|
|||||||
account.api_status = API_STATUS_AUTH_ERROR
|
account.api_status = API_STATUS_AUTH_ERROR
|
||||||
elif error == '211':
|
elif error == '211':
|
||||||
account.api_status = API_STATUS_ACC_EXPIRED
|
account.api_status = API_STATUS_ACC_EXPIRED
|
||||||
|
elif error in ['222', '223']:
|
||||||
|
account.api_status = API_STATUS_KEY_EXPIRED
|
||||||
else:
|
else:
|
||||||
account.api_status = API_STATUS_OTHER_ERROR
|
account.api_status = API_STATUS_OTHER_ERROR
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user