mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-14 06:50:15 +02:00
Added api mask to html added check
This commit is contained in:
parent
4dca4e7ec9
commit
20b9152a1c
@ -1,6 +1,13 @@
|
||||
from django import forms
|
||||
|
||||
from services.managers.eve_api_manager import EveApiManager
|
||||
|
||||
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 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')
|
||||
|
||||
return self.cleaned_data
|
@ -34,3 +34,15 @@ class EveApiManager():
|
||||
|
||||
return ticker
|
||||
|
||||
@staticmethod
|
||||
def check_api_is_type_account(api_id, api_key):
|
||||
try:
|
||||
api = evelink.api.API(api_key=(api_id, api_key))
|
||||
account = evelink.account.Account(api=api)
|
||||
info = account.key_info()
|
||||
return info[0]['type'] == "account"
|
||||
|
||||
except evelink.api.APIError as error:
|
||||
print error
|
||||
|
||||
return False
|
@ -18,7 +18,7 @@
|
||||
Alliance services: CharacterInfo
|
||||
</p>
|
||||
<p class="text-center">
|
||||
<a target="_blank" href="https://community.eveonline.com/support/api-key/CreatePredefined?accessMask=8921088">Create a standard API key</a>
|
||||
<a target="_blank" href="https://community.eveonline.com/support/api-key/CreatePredefined?accessMask=82323776">Create a standard API key</a>
|
||||
<br/>
|
||||
<a target="_blank" href="https://community.eveonline.com/support/api-key/CreatePredefined?accessMask=268435455">Create a full API key</a>
|
||||
</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user