Packages
A Fair Source multi-agent runtime with deterministic agent scoring and replayable run history.
Retired package: Deprecated - superseded — operator console moved to the Syntropy app
Current section
Files
Jump to
Current section
Files
lib/syntropy_web/plugs/require_operator.ex
defmodule SyntropyWeb.Plugs.RequireOperator do
@moduledoc """
Redirects unauthenticated browser requests to the operator login page when
operator auth is enforced.
"""
import Phoenix.Controller, only: [redirect: 2]
import Plug.Conn, only: [halt: 1]
alias SyntropyWeb.OperatorAuth
@spec init(term()) :: term()
def init(opts), do: opts
@spec call(Plug.Conn.t(), term()) :: Plug.Conn.t()
def call(conn, _opts) do
if not OperatorAuth.required?() or OperatorAuth.authenticated?(conn) do
conn
else
conn
|> redirect(to: "/login")
|> halt()
end
end
end