can not login for pending user - #877
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user