can not login for pending user - #877

This commit is contained in:
Laurent GAY
2025-09-13 16:43:00 +02:00
parent e78ff057c2
commit 23cd7333c4
6 changed files with 58 additions and 4 deletions

View File

@@ -92,12 +92,16 @@ defmodule Mobilizon.Service.Auth.Authenticator do
end
end
@spec fetch_user(String.t()) :: User.t() | {:error, :user_not_found}
@spec fetch_user(String.t()) :: User.t() | {:error, :user_not_found} | {:error, :pending}
def fetch_user(nil), do: {:error, :user_not_found}
def fetch_user(email) when not is_nil(email) do
with {:ok, %User{} = user} <- Users.get_user_by_email(email, activated: true) do
user
if user.role == :pending do
{:error, :user_pending}
else
user
end
end
end
end

View File

@@ -28,6 +28,9 @@ defmodule Mobilizon.Service.Auth.MobilizonAuthenticator do
{:user, {:error, :user_not_found}} ->
{:error, :user_not_found}
{:user, {:error, :user_pending}} ->
{:error, :user_pending}
{:acceptable_password, false} ->
{:error, :bad_password}