Skip to content

Commit

Permalink
Fix challenge_factor
Browse files Browse the repository at this point in the history
  • Loading branch information
LauraBeatris committed Dec 13, 2023
1 parent c6d0342 commit 0bf9094
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 6 additions & 4 deletions lib/workos/mfa.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ defmodule WorkOS.MFA do
Parameter options:
* `:authentication_factor_id` - The ID of the Authentication Factor. (required)
* `:sms_template` - A valid phone number for an SMS-enabled device. Required when type is sms.
"""
@spec challenge_factor(String.t(), map()) :: WorkOS.Client.response(AuthenticationChallenge.t())
@spec challenge_factor(WorkOS.Client.t(), String.t(), map()) ::
@spec challenge_factor(map()) :: WorkOS.Client.response(AuthenticationChallenge.t())
@spec challenge_factor(WorkOS.Client.t(), map()) ::
WorkOS.Client.response(AuthenticationChallenge.t())
def challenge_factor(client \\ WorkOS.client(), authentication_factor_id, opts) do
def challenge_factor(client \\ WorkOS.client(), opts)
when is_map_key(opts, :authentication_factor_id) do
WorkOS.Client.post(
client,
AuthenticationChallenge,
Expand All @@ -58,7 +60,7 @@ defmodule WorkOS.MFA do
sms_template: opts[:sms_template]
},
opts: [
path_params: [id: authentication_factor_id]
path_params: [id: opts[:authentication_factor_id]]
]
)
end
Expand Down
5 changes: 1 addition & 4 deletions test/workos/mfa_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ defmodule WorkOS.MFATest do
id: id,
authentication_factor_id: authentication_factor_id
}} =
WorkOS.MFA.challenge_factor(
opts |> Keyword.get(:authentication_factor_id),
opts |> Enum.into(%{})
)
WorkOS.MFA.challenge_factor(opts |> Enum.into(%{}))

refute is_nil(id)
refute is_nil(authentication_factor_id)
Expand Down

0 comments on commit 0bf9094

Please sign in to comment.