From fa60be3675c00709a9c8cd92a3da37bf8bdece6c Mon Sep 17 00:00:00 2001 From: Adarnof Date: Sun, 6 Mar 2016 15:58:11 -0500 Subject: [PATCH] Ensure entered api ID is int Auth accepts these values in either order for building the model, but incorrectly assigns the vcode instead of ID to character models if entered incorrectly which can break certain functions. This is an added layer of stupid-protection to make sure they put the API ID (a number) in the right field. --- eveonline/forms.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/eveonline/forms.py b/eveonline/forms.py index eeba2f9e..d81e1cf5 100644 --- a/eveonline/forms.py +++ b/eveonline/forms.py @@ -16,6 +16,13 @@ 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_api_id(self): + try: + api_id = int(self.cleaned_data['api_id']) + return api_id + except: + raise forms.ValidationError("API ID must be a number") def clean(self): super(UpdateKeyForm, self).clean()