#NEWLINE# def authenticate( self , **credentials ) : #NEWLINE# #INDENT# qs = EmailAddress . objects . filter ( ( Q ( primary = True ) | Q ( verified = True ) ) ) #NEWLINE# try : #NEWLINE# #INDENT# email_address = qs . get ( email__iexact = credentials [ 'username' ] ) #NEWLINE# #UNINDENT# except ( EmailAddress . DoesNotExist , KeyError ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# user = email_address . user #NEWLINE# try : #NEWLINE# #INDENT# if user . check_password ( qs [ 'password' ] ) : #NEWLINE# #INDENT# return user #NEWLINE# #UNINDENT# #UNINDENT# except KeyError : #NEWLINE# #INDENT# return None