diff --git a/CHANGELOG.md b/CHANGELOG.md index 42f4458780..2a9f87a56b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,9 @@ and this project adheres to ### Changed +- Ensure that all the demo accounts are confirmed by default + [#2395](https://github.com/OpenFn/lightning/issues/2395) + ### Fixed ## [v2.7.17] - 2024-08-14 diff --git a/lib/lightning/setup_utils.ex b/lib/lightning/setup_utils.ex index 63a3ffaf46..dddb8b73ec 100644 --- a/lib/lightning/setup_utils.ex +++ b/lib/lightning/setup_utils.ex @@ -6,6 +6,7 @@ defmodule Lightning.SetupUtils do import Ecto.Changeset alias Lightning.Accounts + alias Lightning.Accounts.User alias Lightning.Credentials alias Lightning.Jobs alias Lightning.Projects @@ -49,7 +50,7 @@ defmodule Lightning.SetupUtils do """ def setup_demo(opts \\ [create_super: false]) do %{super_user: super_user, admin: admin, editor: editor, viewer: viewer} = - create_users(opts) + create_users(opts) |> confirm_users() %{ project: openhie_project, @@ -164,6 +165,25 @@ defmodule Lightning.SetupUtils do %{super_user: super_user, admin: admin, editor: editor, viewer: viewer} end + def confirm_users(users) do + confirm_user = fn user -> + case user do + nil -> + :ok + + _ -> + User.confirm_changeset(user) + |> Repo.update!() + end + end + + users + |> Map.values() + |> Enum.each(confirm_user) + + users + end + def create_starter_project(name, project_users) do {:ok, project} = Projects.create_project(