#NEWLINE# def authenticate( self , username = None , password = None ) : #NEWLINE# #INDENT# ' Authenticate a user based on email address as the user name. ' #NEWLINE# if ( ( username is None ) or ( password is None ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# user_profile = get_user_profile_by_email ( username ) #NEWLINE# if ( not password_auth_enabled ( self . realm ) ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# if user_profile . check_password ( password ) : #NEWLINE# #INDENT# return user_profile #NEWLINE# #UNINDENT# #UNINDENT# except UserProfile . DoesNotExist : #NEWLINE# #INDENT# return None