Example #1
0
def try_create_account(sock, name, psswd):
    if mudsys.account_exists(name):
        return False
    elif mudsys.account_creating(name):
        return False
    elif not check_acct_name(name):
        return False
    else:
        # creating a new account
        mud.log_string("Account '" + name + "' is trying to create.")

        # create our new account
        acct = mudsys.create_account(name)
        if acct == None:
            return False
        else:
            mudsys.attach_account_socket(acct, sock)
            mudsys.set_password(acct, psswd)
            sock.pop_ih()
            sock.push_ih(acct_menu_handler, acct_main_menu)

            #sock.push_ih(acct_finish_handler, acct_finish_prompt)

            # log that the account created
            mud.log_string("New account '" + acct.name + "' has created.")

            # register and save the account to disk
            mudsys.do_register(acct)

            return True
    return False
Example #2
0
def try_load_account(sock, name, psswd):
    '''Attempt to load an account with the given name and password.'''
    if not mudsys.account_exists(name):
        return False
    else:
        acct = mudsys.load_account(name)
        if not mudsys.password_matches(acct, psswd):
            return False

        # successful load
        mudsys.attach_account_socket(acct, sock)
        sock.pop_ih()
        sock.push_ih(acct_menu_handler, acct_main_menu)
        return True
    return False