mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 08:36:29 +00:00
UserEnabledPlug: Don't authenticate unconfirmed users.
This commit is contained in:
parent
8521553ad9
commit
f6056e9c9c
2 changed files with 24 additions and 3 deletions
|
@ -10,9 +10,13 @@ defmodule Pleroma.Plugs.UserEnabledPlug do
|
|||
options
|
||||
end
|
||||
|
||||
def call(%{assigns: %{user: %User{deactivated: true}}} = conn, _) do
|
||||
conn
|
||||
|> assign(:user, nil)
|
||||
def call(%{assigns: %{user: %User{} = user}} = conn, _) do
|
||||
if User.auth_active?(user) do
|
||||
conn
|
||||
else
|
||||
conn
|
||||
|> assign(:user, nil)
|
||||
end
|
||||
end
|
||||
|
||||
def call(conn, _) do
|
||||
|
|
|
@ -16,6 +16,23 @@ defmodule Pleroma.Plugs.UserEnabledPlugTest do
|
|||
assert ret_conn == conn
|
||||
end
|
||||
|
||||
test "with a user that's not confirmed and a config requiring confirmation, it removes that user",
|
||||
%{conn: conn} do
|
||||
old = Pleroma.Config.get([:instance, :account_activation_required])
|
||||
Pleroma.Config.put([:instance, :account_activation_required], true)
|
||||
|
||||
user = insert(:user, confirmation_pending: true)
|
||||
|
||||
conn =
|
||||
conn
|
||||
|> assign(:user, user)
|
||||
|> UserEnabledPlug.call(%{})
|
||||
|
||||
assert conn.assigns.user == nil
|
||||
|
||||
Pleroma.Config.put([:instance, :account_activation_required], old)
|
||||
end
|
||||
|
||||
test "with a user that is deactivated, it removes that user", %{conn: conn} do
|
||||
user = insert(:user, deactivated: true)
|
||||
|
||||
|
|
Loading…
Reference in a new issue