Skip to content

Commit

Permalink
change how args are passed into get_or_create_device
Browse files Browse the repository at this point in the history
  • Loading branch information
joshk committed Dec 11, 2023
1 parent d89077b commit 34c0326
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/nerves_hub/devices.ex
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,9 @@ defmodule NervesHub.Devices do
end
end

def get_or_create_device(token_auth: token_auth, identifier: identifier) do
@spec get_or_create_device(TokenAuth.t(), String.t()) ::
{:ok, Device.t()} | {:error, :not_found}
def get_or_create_device(%TokenAuth{} = token_auth, identifier) do
with {:error, :not_found} <-
get_active_device(product_id: token_auth.product_id, identifier: identifier),
{:ok, product} <-
Expand Down
2 changes: 1 addition & 1 deletion lib/nerves_hub_web/channels/device_socket_token_auth.ex
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ defmodule NervesHubWeb.DeviceSocketTokenAuth do
{:ok, identifier} <-
Crypto.verify(token_auth.secret, salt, signature, verification_options),
{:ok, device} <-
Devices.get_or_create_device(token_auth: token_auth, identifier: identifier) do
Devices.get_or_create_device(token_auth, identifier) do
socket =
socket
|> assign(:device, device)
Expand Down

0 comments on commit 34c0326

Please sign in to comment.