#NEWLINE# def authenticate( self , **credentials ) : #NEWLINE# #INDENT# lookup_params = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# if settings . ACCOUNT_EMAIL_AUTHENTICATION : #NEWLINE# #INDENT# ( name , identity ) = ( 'email' , credentials . get ( 'email' ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( name , identity ) = ( 'username' , credentials . get ( 'username' ) ) #NEWLINE# #UNINDENT# if ( identity is None ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# lookup_params [ name ] = identity #NEWLINE# try : #NEWLINE# #INDENT# user = User . objects . get ( ** lookup_params ) #NEWLINE# #UNINDENT# except User . DoesNotExist : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if user . check_password ( credentials [ 'password' ] ) : #NEWLINE# #INDENT# return credentials