<commit_before>import cherrypy
from basefilter import BaseFilter


def defaultLoginScreen(from_page, login = '', errorMsg = ''):
    return """
    <html><body>
        Message: %s
        <form method="post" action="do_login">
            Login: <input type="text" name="login" value="%s" size="10"/><br/>
            Password: <input type="password" name="password" size="10"/><br/>
            <input type="hidden" name="from_page" value="%s"/><br/>
            <input type="submit"/>
        </form>
    </body></html>
    """ % (errorMsg, login, from_page)

def defaultCheckLoginAndPassword(login, password):
    # Dummy checkLoginAndPassword function
    if login != 'login' or password != 'password':
        return u'Wrong login/password'

class SessionAuthenticateFilter(BaseFilter):
    """
    Filter allows for simple forms based authentication and access control
    """
    
    def before_main(self):
        if not cherrypy.config.get('session_authenticate_filter.on', False):
            return
        
        
        checkLoginAndPassword = cherrypy.config.get('session_authenticate_filter.check_login_and_password', defaultCheckLoginAndPassword)
        loginScreen = cherrypy.config.get('session_authenticate_filter.login_screen', defaultLoginScreen)
        notLoggedIn = cherrypy.config.get('session_authenticate_filter.not_logged_in')
        loadUserByUsername = cherrypy.config.get('session_authenticate_filter.load_user_by_username')
        sessionKey = cherrypy.config.get('session_authenticate_filter.session_key', 'username')

        if cherrypy.request.path.endswith('loginScreen'):
            return<commit_msg>Disable session_authenticate_filter is static_filter is on<commit_after>import cherrypy
from basefilter import BaseFilter


def defaultLoginScreen(from_page, login = '', errorMsg = ''):
    return """
    <html><body>
        Message: %s
        <form method="post" action="do_login">
            Login: <input type="text" name="login" value="%s" size="10"/><br/>
            Password: <input type="password" name="password" size="10"/><br/>
            <input type="hidden" name="from_page" value="%s"/><br/>
            <input type="submit"/>
        </form>
    </body></html>
    """ % (errorMsg, login, from_page)

def defaultCheckLoginAndPassword(login, password):
    # Dummy checkLoginAndPassword function
    if login != 'login' or password != 'password':
        return u'Wrong login/password'

class SessionAuthenticateFilter(BaseFilter):
    """
    Filter allows for simple forms based authentication and access control
    """
    
    def before_main(self):
        conf = cherrypy.config.get
        if ((not conf('session_authenticate_filter.on', False))
              or conf('static_filter.on', False)):
            return
        
        checkLoginAndPassword = cherrypy.config.get('session_authenticate_filter.check_login_and_password', defaultCheckLoginAndPassword)
        loginScreen = cherrypy.config.get('session_authenticate_filter.login_screen', defaultLoginScreen)
        notLoggedIn = cherrypy.config.get('session_authenticate_filter.not_logged_in')
        loadUserByUsername = cherrypy.config.get('session_authenticate_filter.load_user_by_username')
        sessionKey = cherrypy.config.get('session_authenticate_filter.session_key', 'username')

        if cherrypy.request.path.endswith('loginScreen'):
            return
{'fraction_non_alphanumeric': 0.11894273127753303, 'fraction_numerical': 0.0023494860499265785, 'mean_word_length': 3.505291005291005, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1075520', 'n_tokens_mistral': 977, 'n_tokens_neox': 935, 'n_words': 187}