Skip to content

Commit 008cd41

Browse files
committed
feat(portaswitch): support login via alias numbers
1 parent 1383740 commit 008cd41

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/bss/adapters/portaswitch/adapter.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ def authenticate(self, user: UserInfo, password: str = None) -> SessionInfo:
115115
password_attr = "h323_password" if is_sip_credentials else "password"
116116

117117
account_info = self._admin_api.get_account_info(**{login_attr: user.login}).get("account_info")
118+
119+
# If the provided identifier refers to an alias, resolve to the master account
120+
if account_info and (master_id := account_info.get("i_master_account")):
121+
account_info = self._admin_api.get_account_info(i_account=master_id).get("account_info")
122+
118123
if not account_info or account_info[password_attr] != password:
119124
raise WebTritErrorException(401, "User authentication error", code="incorrect_credentials")
120125

@@ -165,7 +170,7 @@ def generate_otp(self, user: UserInfo) -> OTPCreateResponse:
165170
if self._portaswitch_settings.ALLOWED_ADDONS:
166171
self._check_allowed_addons(account_info)
167172

168-
i_account = account_info["i_account"]
173+
i_account = account_info.get("i_master_account", account_info["i_account"])
169174
success: int = self._admin_api.create_otp(i_account, self.OTP_DELIVERY_CHANNEL)["success"]
170175
if not success:
171176
raise WebTritErrorException(500, "Unknown error", code="external_api_issue")

0 commit comments

Comments
 (0)