Exemplo n.º 1
0
def login(username=None):
    '''
    Does all the login stuff
    The whole login system is called from this
    '''
    # Check if banned first
    b = User.chkbnid(User.host())
    # cuserid(NULL));
    logger.debug("BANNED %d", b)

    if username:
        username = username.lower()

    user = User.by_username(username)
    if user:
        authenticate(user)
        return user

    # Get the user name
    user = None
    while not user:
        user = input_username(username)
        username = ''

    if user.id:
        # Password checking
        authenticate(user)
    else:
        register(user)
    cls()
    return user
Exemplo n.º 2
0
def show(username):
    user = User.by_username(username)
    if user is None:
        print("\nNo user registered in that name\n\n")
    else:
        print("\n\nUser Data For {}\n".format(user.username))
        print("Name: {}\nPassword: {}\n".format(user.username, user.password))
    return user
Exemplo n.º 3
0
def input_username(username, prompt="By what name shall I call you?\n*\t"):
    if not username:
        username = input(prompt)[:15]

    # Check for legality of names
    try:
        user = User(username)
    except AssertionError as e:
        print(e)
        return None

    user = User.by_username(username)
    if user:
        return user

    # If he/she doesnt exist
    answer = input("Did I get the name right {}? ".format(username)).lower()
    if answer[0] == 'y':
        user = User(username=username)
    return user