Commit 93103baf authored by Antoine Millet's avatar Antoine Millet
Browse files

Rights are now checked for addaccount

parent 7d2e0f5a
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -200,13 +200,14 @@ class CCServer(object):
                                           'connected' % login)
        client.shutdown()

    def check(self, client, method, tql):
    def check(self, client, method, tql=None):
        rights = self.conf.show(client.login)['rights']
        if tql is not None:
            objects = self.list(tql, pure=True)
        for right in rights:
            if not (right['method'] is None or glob(method, right['method'])):
                continue
            if right['tql']:
            if tql is not None and right['tql']:
                objects_right = self.list(right['tql'], pure=True)
                if not objects <= objects_right:
                    continue
+4 −1
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ class OnlineCCHandler(CCHandler):
    def on_disconnect(self, conn):
        self._server.unregister(conn)

    def _check(self, conn, method, tql):
    def _check(self, conn, method, tql=None):
        client = self._server.search_client_by_connection(conn)
        allow = self._server.check(client, method, tql)
        if not allow:
@@ -203,6 +203,9 @@ class CliHandler(OnlineCCHandler):
        '''
        Create a new account with specified login.
        '''

        self._check(conn, 'addaccount')
        
        if role in WelcomeHandler.ROLES:
            self._server.conf.create_account(login, role, password)
        else: