1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2022 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Web.Plugs.EnsureAuthenticatedPlug do
7 Ensures _user_ authentication (app-bound user-unbound tokens are not accepted).
11 import Pleroma.Web.TranslationHelpers
15 use Pleroma.Web, :plug
25 auth_credentials: %{password: _},
26 user: %User{multi_factor_authentication_settings: %{enabled: true}}
32 |> render_error(:forbidden, "Two-factor authentication enabled, you must use a access token.")
36 def perform(%{assigns: %{user: %User{}}} = conn, _) do
40 def perform(conn, _) do
42 |> render_error(:forbidden, "Invalid credentials.")