Skip to content

Commit 5232bc6

Browse files
authored
Add option to fail on conflict (#733)
related to descope/etc#13449
1 parent 782aa70 commit 5232bc6

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

descope/management/user.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,6 +1061,7 @@ def update_email(
10611061
login_id: str,
10621062
email: Optional[str] = None,
10631063
verified: Optional[bool] = None,
1064+
fail_on_conflict: Optional[bool] = None,
10641065
) -> dict:
10651066
"""
10661067
Update the email address for an existing user.
@@ -1069,6 +1070,7 @@ def update_email(
10691070
login_id (str): The login ID of the user to update the email for.
10701071
email (str): The user email address. Leave empty to remove.
10711072
verified (bool): Set to true for the user to be able to login with the email address.
1073+
fail_on_conflict (bool): Set to true to raise an error if the email is used as a login id and already exists.
10721074
10731075
Return value (dict):
10741076
Return dict in the format
@@ -1080,7 +1082,7 @@ def update_email(
10801082
"""
10811083
response = self._http.post(
10821084
MgmtV1.user_update_email_path,
1083-
body={"loginId": login_id, "email": email, "verified": verified},
1085+
body={"loginId": login_id, "email": email, "verified": verified, "failOnConflict": fail_on_conflict},
10841086
)
10851087
return response.json()
10861088

@@ -1089,6 +1091,7 @@ def update_phone(
10891091
login_id: str,
10901092
phone: Optional[str] = None,
10911093
verified: Optional[bool] = None,
1094+
fail_on_conflict: Optional[bool] = None,
10921095
) -> dict:
10931096
"""
10941097
Update the phone number for an existing user.
@@ -1097,6 +1100,7 @@ def update_phone(
10971100
login_id (str): The login ID of the user to update the phone for.
10981101
phone (str): The user phone number. Leave empty to remove.
10991102
verified (bool): Set to true for the user to be able to login with the phone number.
1103+
fail_on_conflict (bool): Set to true to raise an error if the phone is used as a login id and already exists.
11001104
11011105
Return value (dict):
11021106
Return dict in the format
@@ -1108,7 +1112,7 @@ def update_phone(
11081112
"""
11091113
response = self._http.post(
11101114
MgmtV1.user_update_phone_path,
1111-
body={"loginId": login_id, "phone": phone, "verified": verified},
1115+
body={"loginId": login_id, "phone": phone, "verified": verified, "failOnConflict": fail_on_conflict},
11121116
)
11131117
return response.json()
11141118

tests/management/test_user.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1753,6 +1753,7 @@ def test_update_email(self):
17531753
"loginId": "valid-id",
17541754
"email": "a@b.c",
17551755
"verified": None,
1756+
"failOnConflict": None,
17561757
},
17571758
allow_redirects=False,
17581759
verify=True,
@@ -1791,6 +1792,7 @@ def test_update_phone(self):
17911792
"loginId": "valid-id",
17921793
"phone": "+18005551234",
17931794
"verified": True,
1795+
"failOnConflict": None,
17941796
},
17951797
allow_redirects=False,
17961798
verify=True,

0 commit comments

Comments
 (0)