From 1d07248aec7c311c6127ed40364ab43a585d203a Mon Sep 17 00:00:00 2001 From: Benjamin Piouffle Date: Thu, 23 Jan 2025 22:32:17 +0100 Subject: [PATCH] misc fixes (#487) --- apps/cf_jobs/lib/application.ex | 2 +- apps/db/lib/db_schema/user.ex | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/cf_jobs/lib/application.ex b/apps/cf_jobs/lib/application.ex index edd49824..de190a0b 100644 --- a/apps/cf_jobs/lib/application.ex +++ b/apps/cf_jobs/lib/application.ex @@ -23,7 +23,7 @@ defmodule CF.Jobs.Application do # Do not start scheduler in tests children = - if env == :test, + if env == :test or Application.get_env(:cf, :disable_scheduler), do: children, else: children ++ [worker(CF.Jobs.Scheduler, [])] diff --git a/apps/db/lib/db_schema/user.ex b/apps/db/lib/db_schema/user.ex index 30f58abb..887dace1 100644 --- a/apps/db/lib/db_schema/user.ex +++ b/apps/db/lib/db_schema/user.ex @@ -86,8 +86,19 @@ defmodule DB.Schema.User do |> common_changeset(params) |> validate_length(:password, min: 6, max: 256) |> put_encrypted_pw + |> set_unconfirmed_if_new_email(model, params) end + defp set_unconfirmed_if_new_email(changeset, model, %{"email" => email}) do + if model && !is_nil(email) && email != model.email do + put_change(changeset, :email_confirmed, false) + else + changeset + end + end + + defp set_unconfirmed_if_new_email(changeset, _model, _params), do: changeset + @doc """ Generate a changeset to update `reputation` and `today_reputation_gain` without verifying daily limits """