Don't sent reset email when user is disabled
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
53c4f5dfde
commit
71476ee587
|
@ -383,7 +383,7 @@ defmodule Mobilizon.Users do
|
|||
defp user_by_email_query(email, true) do
|
||||
from(
|
||||
u in User,
|
||||
where: u.email == ^email and not is_nil(u.confirmed_at),
|
||||
where: u.email == ^email and not is_nil(u.confirmed_at) and not u.disabled,
|
||||
preload: :default_actor
|
||||
)
|
||||
end
|
||||
|
|
|
@ -757,6 +757,23 @@ defmodule Mobilizon.GraphQL.Resolvers.UserTest do
|
|||
assert hd(res["errors"])["message"] ==
|
||||
"This user can't reset their password"
|
||||
end
|
||||
|
||||
test "test send_reset_password/3 for a deactivated user doesn't send email", %{conn: conn} do
|
||||
{:ok, %User{email: email} = user} =
|
||||
Users.register(%{email: "toto@tata.tld", password: "p4ssw0rd"})
|
||||
|
||||
Users.update_user(user, %{confirmed_at: DateTime.utc_now(), disabled: true})
|
||||
|
||||
res =
|
||||
conn
|
||||
|> AbsintheHelpers.graphql_query(
|
||||
query: @send_reset_password_mutation,
|
||||
variables: %{email: email}
|
||||
)
|
||||
|
||||
assert hd(res["errors"])["message"] ==
|
||||
"No user with this email was found"
|
||||
end
|
||||
end
|
||||
|
||||
describe "Resolver: Reset user's password" do
|
||||
|
|
Loading…
Reference in a new issue