diff --git a/sso/services/__init__.py b/sso/services/__init__.py index 18b1800..9b836df 100644 --- a/sso/services/__init__.py +++ b/sso/services/__init__.py @@ -63,7 +63,7 @@ class BaseService(): """ Login the user and provide cookies back """ pass - def update_groups(self, uid, groups): + def update_groups(self, uid, groups, character=None): """" Update the UID's groups based on the provided list """ pass diff --git a/sso/services/jabber/__init__.py b/sso/services/jabber/__init__.py index ad1b152..8e85ed2 100644 --- a/sso/services/jabber/__init__.py +++ b/sso/services/jabber/__init__.py @@ -94,7 +94,7 @@ class JabberService(BaseService): return grouplist - def update_groups(self, uid, groups): + def update_groups(self, uid, groups, character=None): username, server = uid.split("@") current_groups = self.get_group_list(uid) diff --git a/sso/services/mumble/__init__.py b/sso/services/mumble/__init__.py index 6a9c9a0..fbb1769 100644 --- a/sso/services/mumble/__init__.py +++ b/sso/services/mumble/__init__.py @@ -132,7 +132,7 @@ class MumbleService(BaseService): return acls - def update_groups(self, uid, groups): + def update_groups(self, uid, groups, character=None): """ Update the UID's groups based on the provided list """ user = self.mumblectl.getRegisteredPlayers(self.settings['mumble_server_id'], uid) diff --git a/sso/services/phpbb/__init__.py b/sso/services/phpbb/__init__.py index d1b26c5..dfd7e36 100644 --- a/sso/services/phpbb/__init__.py +++ b/sso/services/phpbb/__init__.py @@ -45,7 +45,7 @@ class PhpBBService(BaseDBService): self.update_groups(username) return { 'username': username, 'password': password } - def update_groups(self, username): + def update_groups(self, username, groups, character=None): self._dbcursor.execute(self.SQL_CHECK_USER, [self._clean_username(username)]) row = self._dbcursor.fetchone() user_id = row['user_id'] diff --git a/sso/services/ts3/__init__.py b/sso/services/ts3/__init__.py index 1912302..6d3436a 100644 --- a/sso/services/ts3/__init__.py +++ b/sso/services/ts3/__init__.py @@ -142,7 +142,7 @@ class TS3Service(BaseService): return outlist - def update_groups(self, uid, groups): + def update_groups(self, uid, groups, character=None): """ Update the UID's groups based on the provided list """ cldbid = self._get_userid(uid) @@ -165,6 +165,15 @@ class TS3Service(BaseService): if g.name in usrgrplist: del usrgrplist[g.name] + # Add to corporation groups + if character and character.corporation: + if character.corporation.name in usrgrplist: + del usrgrplist[character.corporation.name] + else: + if not character.corporation.name in tsgrplist: + tsgrplist[g.name] = self._create_group(character.corporation.name) + self.conn.send_command('servergroupaddclient', {'sgid': tsgrplist[character.corporation.name], 'cldbid': cldbid }) + # Remove ignored and admin groups for k, v in usrgrplist.items(): if not int(v) == self.settings['authed_sgid'] and not int(v) in self.settings['ignore_groups']: diff --git a/sso/tasks.py b/sso/tasks.py index 964b5ae..0baa67b 100644 --- a/sso/tasks.py +++ b/sso/tasks.py @@ -73,4 +73,4 @@ def update_user_access(user): def update_service_groups(user_id): for service in ServiceAccount.objects.filter(user=user_id, active=True).select_related('service__api'): api = service.service.api_class - api.update_groups(service.service_uid, service.user.groups.all()) + api.update_groups(service.service_uid, service.user.groups.all(), service.character)