Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
squi-ddy committed Apr 1, 2024
2 parents 8efea1d + 8d03419 commit ba946e5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion bot/src/cogs/github_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion bot/src/cogs/ms_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
8 changes: 5 additions & 3 deletions bot/src/cogs/ui_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit ba946e5

Please sign in to comment.