Commits

offline committed 759148b

validation function added to final step of openid registration

Comments (0)

Files changed (1)

openauth/forms.py

 from openauth.fields import LoginField, PasswordField
 
 
-
 class RegistrationForm(forms.Form):
     """
     Basic registration form. 
 class OpenIDRegistrationForm(forms.Form):
     login = forms.CharField()
 
+    def clean_login(self):
+        login = self.cleaned_data['login']
+        if openauth.settings.UNIQUE_USERNAME and get_object_or_None(User, username=login):
+            raise forms.ValidationError("This username already taken");
+        return login
+
     def save(self, openid_url):
         user = User.objects.create(username=self.cleaned_data['login'])
         if openauth.settings.OPENID_ACTIVATION_REQUIRED:
         return user
 
 
-
 class NewPasswordForm(forms.Form):
     """
     Form for changing user's password.
     """
-
     password = PasswordField(label=_(u'Password'))
     password_confirmation = PasswordField(label=_(u'Password (confirmation)'))
 
-
-
     def clean_password_confirmation(self):
         pass1 = self.cleaned_data['password']
         pass2 = self.cleaned_data['password_confirmation']
         else:
             return pass1
 
-
     def save(self, user):
         user.set_password(self.cleaned_data['password'])
         user.save()
     """
     Form for email chanage.
     """
-
     email = forms.EmailField(label=_(u'New email'))
 
     def save(self):
         pass
 
 
-
 class EditUserForm(forms.Form):
     def __init__(self, user, *args, **kwargs):
         self.user = user
         self.base_fields['username'] = forms.CharField(max_length=254, initial=user.username)
         super(EditUserForm, self).__init__(*args, **kwargs)
 
-
-
     def save(self):
         self.user.username = self.cleaned_data['username']
         self.user.save()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.