#NEWLINE# def validate( self ) : #NEWLINE# #INDENT# user_manager = current_app . user_manager #NEWLINE# if user_manager . enable_username : #NEWLINE# #INDENT# delattr ( self , 'email' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# delattr ( self , 'username' ) #NEWLINE# #UNINDENT# if ( not super ( LoginForm , self ) . validate ( ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# user = None #NEWLINE# user_email = None #NEWLINE# if user_manager . enable_username : #NEWLINE# #INDENT# user = user_manager . find_user_by_username ( self . username . data ) #NEWLINE# if ( ( not user ) and user_manager . enable_email ) : #NEWLINE# #INDENT# ( user , user_email ) = user_manager . find_user_by_email ( self . username . data ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# ( user , user_email ) = user_manager . find_user_by_email ( self . email . data ) #NEWLINE# #UNINDENT# if ( user and user . password and user_manager . verify_password ( self . password . data , user ) ) : #NEWLINE# #INDENT# return True #NEWLINE# #UNINDENT# if ( user_manager . enable_username and user_manager . enable_email ) : #NEWLINE# #INDENT# username_or_email_field = self . username #NEWLINE# username_or_email_text = _ ( 'Username/Email' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if user_manager . enable_username : #NEWLINE# #INDENT# username_or_email_field = self . username #NEWLINE# username_or_email_text = _ ( 'Username' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# username_or_email_field = self . email #NEWLINE# username_or_email_text = _ ( 'Email' ) #NEWLINE# #UNINDENT# #UNINDENT# if user_manager . show_username_email_does_not_exist : #NEWLINE# #INDENT# if ( not user ) : #NEWLINE# #INDENT# message = _ ( '%(username_or_email)s does not exist' , username_or_email = username_or_email_text ) #NEWLINE# username_or_email_field . errors . append ( message ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# self . password . errors . append ( 'Incorrect Password' ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# message = _ ( 'Incorrect %(username_or_email)s and/or Password' , username_or_email = username_or_email_text ) #NEWLINE# username_or_email_field . errors . append ( message ) #NEWLINE# self . password . errors . append ( message ) #NEWLINE# #UNINDENT# return False