Skip to content

Commit

Permalink
Merge pull request #56 from PropelAuth/Add-Revoke-Pending-Org-Invite
Browse files Browse the repository at this point in the history
add revoke pending org invite
  • Loading branch information
pfvatterott authored Aug 19, 2024
2 parents 0c4f563 + 23203cc commit 8bbf3b3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
6 changes: 6 additions & 0 deletions propelauth_py/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
_validate_org_api_key,
_change_user_role_in_org,
_delete_org,
_revoke_pending_org_invite,
)
from propelauth_py.api.magic_link import _create_magic_link
from propelauth_py.api.token_verification_metadata import (
Expand Down Expand Up @@ -129,6 +130,7 @@
"migrate_user_from_external_source",
"create_org",
"delete_org",
"revoke_pending_org_invite",
"update_org_metadata",
"subscribe_org_to_role_mapping",
"add_user_to_org",
Expand Down Expand Up @@ -464,6 +466,9 @@ def subscribe_org_to_role_mapping(org_id, custom_role_mapping_name):

def delete_org(org_id):
return _delete_org(auth_url, integration_api_key, org_id)

def revoke_pending_org_invite(org_id, invitee_email):
return _revoke_pending_org_invite(auth_url, integration_api_key, org_id, invitee_email)

def add_user_to_org(user_id, org_id, role, additional_roles=[]):
return _add_user_to_org(
Expand Down Expand Up @@ -658,6 +663,7 @@ def validate_api_key(api_key_token):
logout_all_user_sessions=logout_all_user_sessions,
allow_org_to_setup_saml_connection=allow_org_to_setup_saml_connection,
disallow_org_to_setup_saml_connection=disallow_org_to_setup_saml_connection,
revoke_pending_org_invite=revoke_pending_org_invite,
# api key functions
fetch_api_key=fetch_api_key,
fetch_current_api_keys=fetch_current_api_keys,
Expand Down
22 changes: 22 additions & 0 deletions propelauth_py/api/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,28 @@ def _delete_org(auth_url, integration_api_key, org_id):

return True

def _revoke_pending_org_invite(
auth_url,
integration_api_key,
org_id,
invitee_email
):
url = auth_url + "/api/backend/v1/pending_org_invites"
json = {
"org_id": org_id,
"invitee_email": invitee_email
}

response = requests.delete(url, json=json, auth=_ApiKeyAuth(integration_api_key))
if response.status_code == 401:
raise ValueError("integration_api_key is incorrect")
elif response.status_code == 400:
raise BadRequestException(response.json())
elif not response.ok:
raise RuntimeError("Unknown error when revoking pending org invite")

return response.json()


####################
# HELPERS #
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name="propelauth-py",
version="3.1.16",
version="3.1.17",
description="A python authentication library",
long_description=README,
long_description_content_type="text/markdown",
Expand Down
2 changes: 2 additions & 0 deletions tests/test_init_base_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
_validate_org_api_key,
_change_user_role_in_org,
_delete_org,
_revoke_pending_org_invite
)
from propelauth_py.api.magic_link import _create_magic_link
from propelauth_py.api.access_token import _create_access_token
Expand Down Expand Up @@ -106,6 +107,7 @@
_invite_user_to_org,
_resend_email_confirmation,
_logout_all_user_sessions,
_revoke_pending_org_invite
]


Expand Down

0 comments on commit 8bbf3b3

Please sign in to comment.