Skip to content

Commit a8c2865

Browse files
authored
Update verified state (#243)
* Expose verified email/phone on update request related to descope/etc#2455 + tests * remove settings string * Fix linting
1 parent d559bb1 commit a8c2865

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

descope/management/user.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ def update(
177177
user_tenants: List[AssociatedTenant] = None,
178178
picture: str = None,
179179
custom_attributes: dict = None,
180+
verified_email: bool = None,
181+
verified_phone: bool = None,
180182
):
181183
"""
182184
Update an existing user with the given various fields. IMPORTANT: All parameters are used as overrides
@@ -212,6 +214,8 @@ def update(
212214
False,
213215
picture,
214216
custom_attributes,
217+
verified_email,
218+
verified_phone,
215219
),
216220
pswd=self._auth.management_key,
217221
)
@@ -953,8 +957,10 @@ def _compose_update_body(
953957
test: bool,
954958
picture: str,
955959
custom_attributes: dict,
960+
verified_email: bool = None,
961+
verified_phone: bool = None,
956962
) -> dict:
957-
return {
963+
res = {
958964
"loginId": login_id,
959965
"email": email,
960966
"phone": phone,
@@ -965,3 +971,8 @@ def _compose_update_body(
965971
"picture": picture,
966972
"customAttributes": custom_attributes,
967973
}
974+
if verified_email is not None:
975+
res["verifiedEmail"] = verified_email
976+
if verified_phone is not None:
977+
res["verifiedPhone"] = verified_phone
978+
return res

tests/management/test_user.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,38 @@ def test_update(self):
241241
verify=True,
242242
timeout=DEFAULT_TIMEOUT_SECONDS,
243243
)
244+
# Test success flow with verified flags
245+
with patch("requests.post") as mock_post:
246+
mock_post.return_value.ok = True
247+
self.assertIsNone(
248+
self.client.mgmt.user.update(
249+
"id", verified_email=True, verified_phone=False
250+
)
251+
)
252+
mock_post.assert_called_with(
253+
f"{common.DEFAULT_BASE_URL}{MgmtV1.user_update_path}",
254+
headers={
255+
**common.default_headers,
256+
"Authorization": f"Bearer {self.dummy_project_id}:{self.dummy_management_key}",
257+
},
258+
params=None,
259+
json={
260+
"loginId": "id",
261+
"email": None,
262+
"phone": None,
263+
"displayName": None,
264+
"roleNames": [],
265+
"userTenants": [],
266+
"test": False,
267+
"picture": None,
268+
"customAttributes": None,
269+
"verifiedEmail": True,
270+
"verifiedPhone": False,
271+
},
272+
allow_redirects=False,
273+
verify=True,
274+
timeout=DEFAULT_TIMEOUT_SECONDS,
275+
)
244276

245277
def test_delete(self):
246278
# Test failed flows

0 commit comments

Comments
 (0)