Skip to content

Commit

Permalink
fix: proper error instead of match error on not found user
Browse files Browse the repository at this point in the history
docs: update docs
  • Loading branch information
zachdaniel committed Oct 23, 2024
1 parent 68b602d commit 704f763
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions documentation/dsls/DSL:-AshAuthentication.Strategy.OAuth2.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,16 +181,12 @@ defmodule MyApp.Accounts.User do
attribute :email, :ci_string, allow_nil?: false
end

identities do
identity :unique_email, [:email]
end

actions do
create :register_with_example do
create :register_with_oauth2 do
argument :user_info, :map, allow_nil?: false
argument :oauth_tokens, :map, allow_nil?: false
upsert? true
upsert_identity :unique_email
upsert_identity :email

change AshAuthentication.GenerateTokenChange
change fn changeset, _ctx ->
Expand Down
4 changes: 2 additions & 2 deletions lib/ash_authentication.ex
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ defmodule AshAuthentication do
%{subject: to_string(subject)},
Keyword.put(options, :not_found_error?, true)
)
|> Ash.read_one()
|> Ash.read_one(not_found_error?: true)
|> case do
# This is here for backwards compatibility with the old api
# when this argument was not added
Expand Down Expand Up @@ -266,7 +266,7 @@ defmodule AshAuthentication do
})
|> Query.for_read(action_name, %{}, options)
|> Query.filter(^primary_key)
|> Ash.read_one()
|> Ash.read_one(not_found_error?: true)
else
_ ->
{:error, Ash.Error.to_error_class(NotFound.exception([]))}
Expand Down

0 comments on commit 704f763

Please sign in to comment.