Esempio n. 1
0
def set_password(user):
    """
    Prompt for user.password, minimum length.
    """
    # pylint: disable=R0914
    #        Too many local variables
    from x84.bbs import getterminal, echo, ini, LineEditor
    term = getterminal()
    hidden_ch = u'x'
    prompt_password = u'password: '******'   again: '
    msg_empty = u'ENtER A PASSWORd!'
    msg_tooshort = u'TOO ShORt, MUSt bE At lEASt %s.'
    msg_unmatched = u'VERifY MUSt MAtCH!'
    width = ini.CFG.getint('nua', 'max_pass')
    min_pass = ini.CFG.getint('nua', 'min_pass')
    while True:
        echo(u'\r\n\r\n' + term.clear_eol + term.normal + prompt_password)
        led = LineEditor(width)
        led.hidden = hidden_ch
        password = led.read()
        if password == u'' or password is None:
            warning(msg_empty)
        elif len(password) < min_pass:
            warning(msg_tooshort % min_pass)
        else:
            echo(u'\r\n\r\n' + term.clear_eol + term.normal + prompt_verify)
            led = LineEditor(width)
            led.hidden = hidden_ch
            verify = led.read()
            if password != verify:
                warning(msg_unmatched)
                continue
            user.password = password
            return
Esempio n. 2
0
def try_pass(user):
    """
    Prompt for password and authenticate, returns True if succesfull.
    """
    # pylint: disable=R0914
    #         Too many local variables
    from x84.bbs import getsession, getterminal, ini, LineEditor, echo
    session, term = getsession(), getterminal()
    prompt_pass = u'\r\n\r\n  pass: '******'\r\n\r\n  ' + term.yellow_reverse(u"Encrypting ..")
    badpass_msg = (u'\r\n\r\n' + term.red_reverse +
                   u"'%s' login failed." + term.normal)
    max_pass = int(ini.CFG.get('nua', 'max_pass'))
    # prompt for password, disable input tap during, mask input with 'x',
    # and authenticate against user record, performing a script change to
    # topscript if sucessful.
    # pylint: disable=W0212
    #         Access to a protected member _tap_input of a client class
    echo(prompt_pass)
    chk = session._tap_input  # <-- save
    session._tap_input = False
    lne = LineEditor(max_pass)
    lne.hidden = u'x'
    password = lne.read()
    session._tap_input = chk  # restore -->
    if password is not None and 0 != len(password):
        echo(status_auth)
        if user.auth(password):
            return True
    denied(badpass_msg % (user.handle,))
    return False
Esempio n. 3
0
def try_pass(user):
    """
    Prompt for password and authenticate, returns True if succesfull.
    """
    # pylint: disable=R0914
    #         Too many local variables
    from x84.bbs import getsession, getterminal, ini, LineEditor, echo
    session, term = getsession(), getterminal()
    prompt_pass = u'pass: '******'\r\n\r\n  ' + term.yellow_reverse(u"Encrypting ..")
    badpass_msg = (u'\r\n\r\n' + term.red_reverse + u"'%s' login failed." +
                   term.normal)
    max_pass = int(ini.CFG.get('nua', 'max_pass'))
    # prompt for password, disable input tap during, mask input with 'x',
    # and authenticate against user record, performing a script change to
    # topscript if sucessful.
    # pylint: disable=W0212
    #         Access to a protected member _tap_input of a client class
    echo(term.move(term.height, max_pass + 10) + prompt_pass)
    chk = session._tap_input  # <-- save
    session._tap_input = False
    lne = LineEditor(max_pass)
    lne.hidden = u'x'
    password = lne.read()
    session._tap_input = chk  # restore -->
    if password is not None and 0 != len(password):
        echo(status_auth)
        if user.auth(password):
            return True
    denied(badpass_msg % (user.handle, ))
    return False