mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-14 15:00:16 +02:00
Added a check on the api key for duplicate keys
This commit is contained in:
parent
a35f36685f
commit
cdddfc8153
@ -108,7 +108,7 @@ def remove_from_databases(user, groups, syncgroups):
|
||||
update_forum_groups(user)
|
||||
|
||||
|
||||
#run every minute
|
||||
# Run every minute
|
||||
@periodic_task(run_every=crontab(minute="*/1"))
|
||||
def run_databaseUpdate():
|
||||
users = User.objects.all()
|
||||
@ -119,7 +119,7 @@ def run_databaseUpdate():
|
||||
remove_from_databases(user, groups, syncgroups)
|
||||
|
||||
|
||||
#run at midnight everyday
|
||||
# Run every 3 hours
|
||||
@periodic_task(run_every=crontab(minute=0, hour="*/3"))
|
||||
def run_api_refresh():
|
||||
users = User.objects.all()
|
||||
|
@ -1,11 +1,16 @@
|
||||
from django import forms
|
||||
from services.managers.eve_api_manager import EveApiManager
|
||||
from eveonline.managers import EveManager
|
||||
|
||||
|
||||
class UpdateKeyForm(forms.Form):
|
||||
api_id = forms.CharField(max_length=254, required=True, label="Key ID")
|
||||
api_key = forms.CharField(max_length=254, required=True, label="Verification Code")
|
||||
|
||||
def clean(self):
|
||||
if EveManager.check_if_api_key_pair_exist(self.cleaned_data['api_id']):
|
||||
raise forms.ValidationError(u'API key already exist')
|
||||
|
||||
if not EveApiManager.check_api_is_type_account(self.cleaned_data['api_id'],
|
||||
self.cleaned_data['api_key']):
|
||||
raise forms.ValidationError(u'API not of type account')
|
||||
|
@ -67,6 +67,13 @@ class EveManager:
|
||||
if EveApiKeyPair.objects.filter(user=user).exists():
|
||||
return EveApiKeyPair.objects.filter(user=user)
|
||||
|
||||
@staticmethod
|
||||
def check_if_api_key_pair_exist(api_id):
|
||||
if EveApiKeyPair.objects.filter(api_id=api_id).exists():
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def delete_api_key_pair(api_id, user_id):
|
||||
if EveApiKeyPair.objects.filter(api_id=api_id).exists():
|
||||
|
Loading…
x
Reference in New Issue
Block a user