diff --git a/bot/src/cogs/github_auth.py b/bot/src/cogs/github_auth.py index bb3e479..1e09e31 100644 --- a/bot/src/cogs/github_auth.py +++ b/bot/src/cogs/github_auth.py @@ -63,7 +63,9 @@ async def verify(self, interaction: Interaction) -> None: return await send_error(interaction, "You have already linked your GitHub account!", ephemeral=True) # generate auth flow - state = uuid.uuid4().hex + while (state := uuid.uuid4().hex) in self.github_auth_flows: + pass + github_link = f"https://github.com/login/oauth/authorize?client_id={config.github_client_id}&state={state}" # add to pending auth flows diff --git a/bot/src/cogs/ms_auth.py b/bot/src/cogs/ms_auth.py index 32c97b2..1cd4e69 100644 --- a/bot/src/cogs/ms_auth.py +++ b/bot/src/cogs/ms_auth.py @@ -146,7 +146,8 @@ async def get_real_ms_auth_link(self, data) -> Optional[Union[str, Literal[False return self.auth_flows.get(state, (0, 0, {}))[2].get("auth_uri") def get_ms_auth_link(self, member_id: int) -> str: - state = uuid.uuid4().hex + while (state := uuid.uuid4().hex) in self.auth_flows: + pass auth_flow = self.application.initiate_auth_code_flow( scopes=["User.Read"], diff --git a/bot/src/cogs/ui_helper.py b/bot/src/cogs/ui_helper.py index d6ba97a..280e9a3 100644 --- a/bot/src/cogs/ui_helper.py +++ b/bot/src/cogs/ui_helper.py @@ -53,12 +53,14 @@ def register_callback(self, callback_name: str, callback: ButtonCallbackFactory) self.callbacks[callback_name] = callback def get_button(self, callback_name: str, callback_args: Collection[Any], **kwargs) -> Button: - button_id = uuid.uuid4().hex + while (button_id := uuid.uuid4().hex) in self.pending: + pass + + self.pending[button_id] = (callback_name, callback_args) + kwargs["custom_id"] = button_id button = Button(**kwargs) - self.pending[button_id] = (callback_name, callback_args) - return button @Cog.listener()