#NEWLINE# def clean( self ) : #NEWLINE# #INDENT# username = self . cleaned_data . get ( 'username' ) #NEWLINE# password = self . cleaned_data . get ( 'password' ) #NEWLINE# message = self . ERROR_MESSAGE #NEWLINE# if ( username and password ) : #NEWLINE# #INDENT# self . user_cache = authenticate ( username = username , password = password ) #NEWLINE# if ( self . user_cache is None ) : #NEWLINE# #INDENT# if ( '@' in username ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# user = User . objects . get ( email = username ) #NEWLINE# #UNINDENT# except ( User . DoesNotExist , User . MultipleObjectsReturned ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if user . check_password ( password ) : #NEWLINE# #INDENT# message = ( _ ( "Your e-mail address is not your username. Try '%s' instead." ) % user . username ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# raise ValidationError ( message ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not self . user_cache . is_active ) : #NEWLINE# #INDENT# raise ValidationError ( message ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# self . check_for_test_cookie ( ) #NEWLINE# return password . cleaned_data