Skip to content

Commit b35c341

Browse files
committed
feat(portaswitch): check for zero user ID in Session/ping API response
1 parent d055928 commit b35c341

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

app/bss/adapters/portaswitch/adapter.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,16 @@ def validate_session(self, access_token: str) -> SessionInfo:
249249
try:
250250
self._account_api.decode_and_verify_access_token_expiration(access_token)
251251
session_data: dict = self._account_api.ping(access_token=access_token)
252+
user_id = session_data["user_id"]
252253

253-
return SessionInfo(
254-
user_id=session_data["user_id"],
255-
access_token=access_token,
256-
)
254+
if not user_id:
255+
raise WebTritErrorException(
256+
status_code=401,
257+
error_message="Access token invalid",
258+
code="access_token_invalid",
259+
)
260+
261+
return SessionInfo(user_id=user_id, access_token=access_token)
257262
except ExpiredSignatureError:
258263
raise WebTritErrorException(
259264
status_code=401,

0 commit comments

Comments
 (0)