Commit 2f0eb085 authored by Antoine Millet's avatar Antoine Millet
Browse files

Fixed accounts.

parent c0a78d39
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ class CCConf(object):
    '''

    CONF_TEMPLATE = {'password': None,
                     'type': None,
                     'role': None,
                     'tags': {},
                     'perms': None}

@@ -188,6 +188,11 @@ class CCConf(object):

        conf = self._get_conf(login)
        passwd_conf = conf['password']

        # Check if account logging is disabled:
        if passwd_conf is None:
            return None

        is_valid = False
        m = CCConf.RE_SALTPW.match(passwd_conf)
        if m is None:
@@ -250,7 +255,7 @@ class CCConf(object):
        logging.debug('Removed tag %s for %s account' % (login, tag))
        conf = self._get_conf(login)
        if tag in conf['tags']:
            conf['tags'][tag]
            del conf['tags'][tag]
        self._set_conf(login, conf)

    @_writer
@@ -270,7 +275,7 @@ class CCConf(object):
            raise CCConf.UnknownAccount('%s is not a file' % filename)

    @_writer
    def create_account(self, login, password, role):
    def create_account(self, login, role, password):
        '''
        Create a new account.

@@ -286,9 +291,10 @@ class CCConf(object):
            raise CCConf.AlreadyExistingAccount('%s found' % filename)
        else:
            conf = CCConf.CONF_TEMPLATE.copy()
            conf['password'] = self._hash_password(password)
            conf['role'] = role

            conf['role'] = role
            if password is not None:
                conf['password'] = self._hash_password(password)
            self._set_conf(login, conf, create=True)

    def list_accounts(self):
+3 −3
Original line number Diff line number Diff line
@@ -120,11 +120,11 @@ class ClientHandler(OnlineCCHandler):

    @pure
    @listed
    def adduser(self, login, password, role):
    def addaccount(self, login, role, password=None):
        '''
        Create a new account with specified login.
        '''
        self._server.conf.create_account(login, password, role)
        self._server.conf.create_account(login, role, password)

    @pure
    @listed
@@ -152,7 +152,7 @@ class ClientHandler(OnlineCCHandler):

    @pure
    @listed
    def deluser(self, login):
    def delaccount(self, login):
        '''
        Delete the account with specified login.
        '''