File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,8 @@ async def __call__(
131131 if not self .bot_only and self .find_installation_available :
132132 # since v1.1, this is the default way
133133 try :
134+ # Note that this is the latest information for the org/workspace.
135+ # The installer may not be the user associated with this incoming request.
134136 installation : Optional [
135137 Installation
136138 ] = await self .installation_store .async_find_installation (
@@ -143,6 +145,10 @@ async def __call__(
143145 return None
144146
145147 if installation .user_id != user_id :
148+ # First off, remove the user token as the installer is a different user
149+ installation .user_token = None
150+ installation .user_scopes = []
151+
146152 # try to fetch the request user's installation
147153 # to reflect the user's access token if exists
148154 user_installation = (
@@ -154,6 +160,7 @@ async def __call__(
154160 )
155161 )
156162 if user_installation is not None :
163+ # Overwrite the installation with the one for this user
157164 installation = user_installation
158165
159166 bot_token , user_token = installation .bot_token , installation .user_token
Original file line number Diff line number Diff line change @@ -131,6 +131,8 @@ def __call__(
131131 if not self .bot_only and self .find_installation_available :
132132 # since v1.1, this is the default way
133133 try :
134+ # Note that this is the latest information for the org/workspace.
135+ # The installer may not be the user associated with this incoming request.
134136 installation : Optional [
135137 Installation
136138 ] = self .installation_store .find_installation (
@@ -143,6 +145,10 @@ def __call__(
143145 return None
144146
145147 if installation .user_id != user_id :
148+ # First off, remove the user token as the installer is a different user
149+ installation .user_token = None
150+ installation .user_scopes = []
151+
146152 # try to fetch the request user's installation
147153 # to reflect the user's access token if exists
148154 user_installation = self .installation_store .find_installation (
@@ -152,6 +158,7 @@ def __call__(
152158 is_enterprise_install = context .is_enterprise_install ,
153159 )
154160 if user_installation is not None :
161+ # Overwrite the installation with the one for this user
155162 installation = user_installation
156163
157164 bot_token , user_token = installation .bot_token , installation .user_token
You can’t perform that action at this time.
0 commit comments