Update User generator for tests.
This commit is contained in:
@@ -3,6 +3,7 @@ defmodule DecentralisedBookIndex.Generators do
|
|||||||
|
|
||||||
use Ash.Generator
|
use Ash.Generator
|
||||||
alias DecentralisedBookIndex.Metadata
|
alias DecentralisedBookIndex.Metadata
|
||||||
|
alias DecentralisedBookIndex.Accounts
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Generates user changesets with the `:register_with_password` action.
|
Generates user changesets with the `:register_with_password` action.
|
||||||
@@ -19,6 +20,10 @@ defmodule DecentralisedBookIndex.Generators do
|
|||||||
password_confirmation: "password"
|
password_confirmation: "password"
|
||||||
],
|
],
|
||||||
overrides: opts,
|
overrides: opts,
|
||||||
|
after_action: fn user ->
|
||||||
|
role = opts[:role] || :user
|
||||||
|
Accounts.User.set_role!(user, role, authorize?: false)
|
||||||
|
end,
|
||||||
authorize?: false
|
authorize?: false
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user