Page 1 of 1

How does work /login ?

Posted: Mon Dec 28, 2015 2:33 pm
by Xaxime
Arguments password are saved into "client.exe", or the player calls the server with the number to connect, and only server has the password ?

Thank you, I'm curious about how does the game work.

Re: How does work /login ?

Posted: Mon May 16, 2016 2:24 pm
by Amatt
In the server's config, the passwords are defined in this manor
Code: Select all
"passwords" : {
        "admin" : ["adminpass"],
        "moderator" : ["modpass"],
        "guard" : ["guardpass"],
        "trusted" : ["trustedpass"]
    },
They are arrays that can be modified to have as many passwords as you would like.

The code for the login command (located in commands.py) is
Code: Select all
def login(connection, password):
    """
    Login as a user type
    """
    if connection not in connection.protocol.players:
        raise KeyError()
    for user_type, passwords in connection.protocol.passwords.iteritems():
        if password in passwords:
            if user_type in connection.user_types:
                return "You're already logged in as %s" % user_type
            return connection.on_user_login(user_type, True)
    if connection.login_retries is None:
        connection.login_retries = connection.protocol.login_retries - 1
    else:
        connection.login_retries -= 1
    if not connection.login_retries:
        connection.kick('Ran out of login attempts')
        return
    return 'Invalid password - you have %s tries left' % (
        connection.login_retries)
The passwords are stored on the server in the config. The command /login <password> checks if the password is in the config, and if it is, it will log you in, otherwise, it will decrees your attempt count until you hit 0 or the correct password. If you hit 0, you will be banned.

Hope this helps you understand it a bit better.