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.
This commit is contained in:
Adarnof 2016-03-06 15:58:11 -05:00
parent b6446f255e
commit fa60be3675

View File

@ -17,6 +17,13 @@ class UpdateKeyForm(forms.Form):
api_id = forms.CharField(max_length=254, required=True, label="Key ID") api_id = forms.CharField(max_length=254, required=True, label="Key ID")
api_key = forms.CharField(max_length=254, required=True, label="Verification Code") 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): def clean(self):
super(UpdateKeyForm, self).clean() super(UpdateKeyForm, self).clean()