Skip to content

Commit

Permalink
Replace other magic_auth_challenge_id references
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatascastro12 committed Aug 24, 2023
1 parent 5653606 commit 51802ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions tests/test_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def test_authenticate_with_magic_auth(
):
code = "test_auth"
expires_in = 3600
magic_auth_challenge_id = "magic_auth_challenge_id"
user = "user_01H7ZGXFP5C6BBQY6Z7277ZCT0"
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
ip_address = "192.0.0.1"

Expand All @@ -217,7 +217,7 @@ def test_authenticate_with_magic_auth(
response = self.users.authenticate_with_magic_auth(
code=code,
expires_in=expires_in,
magic_auth_challenge_id=magic_auth_challenge_id,
user=user,
user_agent=user_agent,
ip_address=ip_address,
)
Expand All @@ -228,7 +228,7 @@ def test_authenticate_with_magic_auth(
assert request["json"]["code"] == code
assert request["json"]["user_agent"] == user_agent
assert request["json"]["expires_in"] == expires_in
assert request["json"]["magic_auth_challenge_id"] == magic_auth_challenge_id
assert request["json"]["user_id"] == user
assert request["json"]["ip_address"] == ip_address
assert request["json"]["client_id"] == "client_b27needthisforssotemxo"
assert request["json"]["client_secret"] == "sk_abdsomecharactersm284"
Expand Down Expand Up @@ -344,16 +344,16 @@ def test_send_verification_email(self, capture_and_mock_request, mock_user):
assert response["id"] == "user_01H7ZGXFP5C6BBQY6Z7277ZCT0"

def test_verify_email(self, capture_and_mock_request, mock_user):
magic_auth_challenge_id = "auth_challenge_123"
user = "user_01H7ZGXFP5C6BBQY6Z7277ZCT0"
code = "code_123"

url, _ = capture_and_mock_request("post", mock_user, 200)
url, request = capture_and_mock_request("post", mock_user, 200)

response = self.users.verify_email(
magic_auth_challenge_id=magic_auth_challenge_id, code=code
)
response = self.users.verify_email(user=user, code=code)

assert url[0].endswith("users/verify_email")
assert request["json"]["user_id"] == user
assert request["json"]["code"] == code
assert response["id"] == "user_01H7ZGXFP5C6BBQY6Z7277ZCT0"

def test_send_magic_auth_code(self, capture_and_mock_request, mock_user):
Expand Down
14 changes: 7 additions & 7 deletions workos/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def remove_user_from_organization(self, user, organization):
def authenticate_with_magic_auth(
self,
code,
magic_auth_challenge_id,
user,
expires_in=None,
ip_address=None,
user_agent=None,
Expand All @@ -206,7 +206,7 @@ def authenticate_with_magic_auth(
Kwargs:
code (str): The one-time code that was emailed to the user.
magic_auth_challenge_id (str): The challenge ID returned from when the one-time code was sent to the user.
user (str): The unique ID of the User who will be authenticated.
expires_in (int): The length of the session in minutes. Defaults to 1 day, 1440. (Optional)
ip_address (str): The IP address of the request from the user who is attempting to authenticate. (Optional)
user_agent (str): The user agent of the request from the user who is attempting to authenticate. (Optional)
Expand All @@ -223,7 +223,7 @@ def authenticate_with_magic_auth(
"client_id": workos.client_id,
"client_secret": workos.api_key,
"code": code,
"magic_auth_challenge_id": magic_auth_challenge_id,
"user_id": user,
"grant_type": "urn:workos:oauth:grant-type:magic-auth:code",
}

Expand Down Expand Up @@ -439,15 +439,15 @@ def send_verification_email(

def verify_email(
self,
magic_auth_challenge_id,
user,
code,
):
"""Verifies user email using one-time code that was sent to the user.
Kwargs:
magic_auth_challenge_id (str): The challenge ID returned from the send verification email endpoint.
user (str): The unique ID of the User whose email address will be verified.
code (str): The unique ID of the User whose email address will be verified.
code (str): The one-time code emailed to the user.
Returns:
dict: User response from WorkOS.
Expand All @@ -456,7 +456,7 @@ def verify_email(
headers = {}

payload = {
"magic_auth_challenge_id": magic_auth_challenge_id,
"user_id": user,
"code": code,
}

Expand Down

0 comments on commit 51802ea

Please sign in to comment.