def __create_user(self, user, password=False): from .auth_hooks import WikiJSService name = NameFormatter(WikiJSService(), user).format_name() if not password: password = get_random_string(15) groups = [WikiJSManager._sanitize_groupname(user.profile.state.name)] for g in user.groups.all(): groups.append(WikiJSManager._sanitize_groupname(str(g))) group_list = self.__generate_group_list(groups) data = json.loads( self.client.execute(_create_user_mutation, variables={ "group_list": group_list, "email": user.email.lower(), "name": name, "pass": password })) logger.debug("API returned: {}".format(data)) if data["data"]["users"]["create"]["responseResult"]["succeeded"]: uid = self.__find_user(user.lower()) if uid: WikiJs.objects.update_or_create(user=user, uid=uid) return uid else: logger.error("WikiJs unable to Create User. {}".format( data["data"]["users"]["create"]["responseResult"]["message"])) return False
def link_sso(self, token, link): character: EveCharacter = EveCharacter.objects.get_character_by_id( token.character_id ) or EveCharacter.objects.create_character(token.character_id) formatted_name = NameFormatter( MumbleService(), PseudoUser(username=character.character_name, main_character=character), ).format_name() display_name = f"{app_settings.MUMBLE_TEMPS_SSO_PREFIX}{formatted_name}" return self.create_temp_user(display_name)
def link_sso(request, token, link): connect_url = None try: char = EveCharacter.objects.get(character_id=token.character_id) except ObjectDoesNotExist: try: #create a new character, we should not get here. char = EveCharacter.objects.update_character(token.character_id) except: pass ## yeah... aint gonna happen except MultipleObjectsReturned: pass # authenticator woont care... but the DB will be unhappy. username = get_random_string(10) while TempUser.objects.filter(username=username).exists(): # force unique username = get_random_string(10) password = get_random_string(15) display_name = "{}{}".format( app_settings.MUMBLE_TEMPS_SSO_PREFIX, NameFormatter(MumbleService(), psudo_user(char, username)).format_name()) temp_user = TempUser.objects.create(username=username, password=password, name=display_name, expires=link.expires, templink=link, character_id=char.character_id) connect_url = "{}:{}@{}".format(username, password, settings.MUMBLE_URL) context = { 'temp_user': temp_user, 'link': link, 'connect_url': connect_url, 'mumble': settings.MUMBLE_URL, } return render(request, 'mumbletemps/link.html', context)
def _update_user(self, user): from .auth_hooks import WikiJSService groups = [WikiJSManager._sanitize_groupname(user.profile.state.name)] for g in user.groups.all(): groups.append(WikiJSManager._sanitize_groupname(str(g))) group_list = self.__generate_group_list(groups) name = NameFormatter(WikiJSService(), user).format_name() data = json.loads( self.client.execute(_update_user_mutation, variables={ "uid": user.wikijs.uid, "name": name, "group_list": group_list })) result = data["data"]["users"]["update"]["responseResult"]["succeeded"] if not result: logger.error("WikiJs unable to update User. {}".format( data["data"]["users"]["update"]["responseResult"]["message"])) return result
def get_username(user): from .auth_hooks import XenforoService return NameFormatter(XenforoService(), user).format_name()
def get_username(user): from .auth_hooks import Phpbb3Service return NameFormatter(Phpbb3Service(), user).format_name()
def get_username(user): from .auth_hooks import OpenfireService return NameFormatter(OpenfireService(), user).format_name()
def get_nickname(user): from .auth_hooks import DiscordService return NameFormatter(DiscordService(), user).format_name()
def get_username(user): from .auth_hooks import Teamspeak3Service return NameFormatter(Teamspeak3Service(), user).format_name()
def get_username(user): from .auth_hooks import MumbleService return NameFormatter(MumbleService(), user).format_name()
def get_username(user): from .auth_hooks import DokuwikiService return NameFormatter(DokuwikiService(), user).format_name()