mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Now validates API key to see if its already been registered
This commit is contained in:
13
sso/forms.py
13
sso/forms.py
@@ -1,12 +1,21 @@
|
||||
from django import forms
|
||||
|
||||
from eve_api.models.api_player import EVEAccount
|
||||
from sso.models import ServiceAccount, Service
|
||||
|
||||
class EveAPIForm(forms.Form):
|
||||
user_id = forms.CharField(max_length=10)
|
||||
api_key = forms.CharField(max_length=100)
|
||||
user_id = forms.CharField(label = u'User ID', max_length=10)
|
||||
api_key = forms.CharField(label = u'API Key', max_length=100)
|
||||
description = forms.CharField(max_length=100)
|
||||
|
||||
def clean(self):
|
||||
try:
|
||||
eaccount = EVEAccount.objects.get(api_user_id=self.cleaned_data['user_id'])
|
||||
except EVEAccount.DoesNotExist:
|
||||
return self.cleaned_data
|
||||
else:
|
||||
raise forms.ValidationError("This API User ID is already registered")
|
||||
|
||||
class ServiceUsernameField(forms.CharField):
|
||||
def clean(self, request, initial=None):
|
||||
field = super(ServiceUsernameField, self).clean(request)
|
||||
|
||||
Reference in New Issue
Block a user