mirror of
https://github.com/team-alembic/ash_authentication.git
synced 2024-09-19 12:52:55 +12:00
fix: PasswordValidation should associate errors with the field being … (#279)
This commit is contained in:
parent
33ed10ae59
commit
2c4d8b296f
3 changed files with 3 additions and 4 deletions
|
@ -3,7 +3,7 @@ defmodule AshAuthentication.Errors.AuthenticationFailed do
|
|||
A generic, authentication failed error.
|
||||
"""
|
||||
use Ash.Error.Exception
|
||||
def_ash_error([:strategy, caused_by: %{}], class: :forbidden)
|
||||
def_ash_error([:field, :strategy, caused_by: %{}], class: :forbidden)
|
||||
import AshAuthentication.Debug
|
||||
|
||||
@type t :: Exception.t()
|
||||
|
|
|
@ -62,6 +62,7 @@ defmodule AshAuthentication.Strategy.Password.PasswordValidation do
|
|||
else
|
||||
{:error,
|
||||
AuthenticationFailed.exception(
|
||||
field: password_arg,
|
||||
strategy: strategy,
|
||||
changeset: changeset
|
||||
)}
|
||||
|
|
|
@ -21,7 +21,7 @@ defmodule AshAuthentication.Strategy.Password.PasswordValidationTest do
|
|||
test "when provided with an incorrect password, it fails vailidation" do
|
||||
user = build_user()
|
||||
|
||||
assert {:error, error} =
|
||||
assert {:error, %AuthenticationFailed{field: :current_password}} =
|
||||
user
|
||||
|> Changeset.new(%{})
|
||||
|> Changeset.set_argument(:current_password, password())
|
||||
|
@ -29,8 +29,6 @@ defmodule AshAuthentication.Strategy.Password.PasswordValidationTest do
|
|||
strategy_name: :password,
|
||||
password_argument: :current_password
|
||||
)
|
||||
|
||||
assert is_struct(error, AuthenticationFailed)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue