Skip to content

Commit 1588c9f

Browse files
authored
Authentication API, the Database classs, Add the organization param to the change_password method (#539)
### Changes Authentication API, the Database class, added the `organization` param to the `change_password` method. ### References https://auth0.com/docs/api/authentication#change-password ### Testing - [x] This change adds unit test coverage ### Checklist - [x] I have read the [Auth0 general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md) - [x] I have read the [Auth0 Code of Conduct](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md) - [x] All existing and new tests complete without errors
2 parents 89343d9 + 4b40a0c commit 1588c9f

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

auth0/authentication/database.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,27 @@ def signup(
7979
return data
8080

8181
def change_password(
82-
self, email: str, connection: str, password: str | None = None
82+
self,
83+
email: str,
84+
connection: str,
85+
password: str | None = None,
86+
organization: str | None = None,
8387
) -> str:
8488
"""Asks to change a password for a given user.
8589
8690
email (str): The user's email address.
8791
8892
connection (str): The name of the database connection where this user should be created.
93+
94+
organization (str, optional): The id of the Organization associated with the user.
8995
"""
9096
body = {
9197
"client_id": self.client_id,
9298
"email": email,
9399
"connection": connection,
94100
}
101+
if organization:
102+
body["organization"] = organization
95103

96104
data: str = self.post(
97105
f"{self.protocol}://{self.domain}/dbconnections/change_password",

auth0/test/authentication/test_database.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,25 @@ def test_change_password(self, mock_post):
7878
"connection": "conn",
7979
},
8080
)
81+
82+
@mock.patch("auth0.rest.RestClient.post")
83+
def test_change_password_with_organization_param(self, mock_post):
84+
d = Database("my.domain.com", "cid")
85+
86+
# ignores the password argument
87+
d.change_password(
88+
email="[email protected]", password="pswd", connection="conn", organization="org_id"
89+
)
90+
91+
args, kwargs = mock_post.call_args
92+
93+
self.assertEqual(args[0], "https://my.domain.com/dbconnections/change_password")
94+
self.assertEqual(
95+
kwargs["data"],
96+
{
97+
"client_id": "cid",
98+
"email": "[email protected]",
99+
"connection": "conn",
100+
"organization": "org_id",
101+
},
102+
)

0 commit comments

Comments
 (0)