Packages

A flexible authentication (and more) solution for Phoenix

Current section

Files

Jump to
haytni lib haytni_web plugs current_user_plug.ex
Raw

lib/haytni_web/plugs/current_user_plug.ex

defmodule Haytni.CurrentUserPlug do
import Plug.Conn
def init(options) do
options
end
def call(conn, options) do
scope = Keyword.get(options, :scope, :user)
{conn, user} = Haytni.find_user(conn)
assign(conn, :"current_#{scope}", user)
end
end