Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions descope/management/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ def invite(
sso_app_ids: Optional[List[str]] = None,
template_id: str = "",
test: bool = False,
locale: Optional[str] = None, # locale for the invite message
) -> dict:
"""
Create a new user and invite them via an email / text message.
Expand Down Expand Up @@ -283,6 +284,7 @@ def invite(
additional_login_ids,
sso_app_ids,
template_id,
locale,
),
)
return response.json()
Expand All @@ -293,6 +295,7 @@ def invite_batch(
invite_url: Optional[str] = None,
send_mail: Optional[bool] = None, # send invite via mail, default is according to project settings
send_sms: Optional[bool] = None, # send invite via text message, default is according to project settings
locale: Optional[str] = None, # locale for the invite message
) -> dict:
"""
Create users in batch and invite them via an email / text message.
Expand All @@ -313,6 +316,7 @@ def invite_batch(
invite_url,
send_mail,
send_sms,
locale,
),
)
return response.json()
Expand Down Expand Up @@ -1860,6 +1864,7 @@ def _compose_create_body(
additional_login_ids: Optional[List[str]],
sso_app_ids: Optional[List[str]] = None,
template_id: str = "",
locale: Optional[str] = None,
) -> dict:
body = User._compose_update_body(
login_id=login_id,
Expand Down Expand Up @@ -1890,6 +1895,8 @@ def _compose_create_body(
body["sendSMS"] = send_sms
if template_id != "":
body["templateId"] = template_id
if locale is not None:
body["locale"] = locale
return body

@staticmethod
Expand All @@ -1898,6 +1905,7 @@ def _compose_create_batch_body(
invite_url: Optional[str],
send_mail: Optional[bool],
send_sms: Optional[bool],
locale: Optional[str] = None,
) -> dict:
usersBody = []
for user in users:
Expand Down Expand Up @@ -1940,6 +1948,8 @@ def _compose_create_batch_body(
body["sendMail"] = send_mail
if send_sms is not None:
body["sendSMS"] = send_sms
if locale is not None:
body["locale"] = locale
return body

@staticmethod
Expand Down
6 changes: 6 additions & 0 deletions tests/management/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ def test_invite(self):
send_sms=True,
sso_app_ids=["app1", "app2"],
template_id="tid",
locale="en",
)
user = resp["user"]
self.assertEqual(user["id"], "u1")
Expand Down Expand Up @@ -271,6 +272,7 @@ def test_invite(self):
"additionalLoginIds": None,
"ssoAppIDs": ["app1", "app2"],
"templateId": "tid",
"locale": "en",
},
follow_redirects=False,
verify=SSLMatcher(),
Expand Down Expand Up @@ -320,6 +322,7 @@ def test_invite_batch(self):
users=[user],
invite_url="invite.me",
send_sms=True,
locale="en",
)
users = resp["users"]
self.assertEqual(users[0]["id"], "u1")
Expand Down Expand Up @@ -361,6 +364,7 @@ def test_invite_batch(self):
"invite": True,
"inviteUrl": "invite.me",
"sendSMS": True,
"locale": "en",
}
mock_post.assert_called_with(
f"{common.DEFAULT_BASE_URL}{MgmtV1.user_create_batch_path}",
Expand Down Expand Up @@ -400,6 +404,7 @@ def test_invite_batch(self):
users=[user],
invite_url="invite.me",
send_sms=True,
locale="en",
)

del expected_users["users"][0]["hashedPassword"]
Expand All @@ -423,6 +428,7 @@ def test_invite_batch(self):
users=[user],
invite_url="invite.me",
send_sms=True,
locale="en",
)

del expected_users["users"][0]["password"]
Expand Down
Loading