From 0f2c57cd5ac4b6623839742cd44caa77f1aef676 Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Sat, 27 Feb 2010 17:55:15 +0000 Subject: [PATCH] Now validates API key to see if its already been registered --- sso/forms.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sso/forms.py b/sso/forms.py index b728650..b135018 100644 --- a/sso/forms.py +++ b/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)