mirror of
https://github.com/plausible/analytics.git
synced 2024-12-25 18:48:06 +03:00
21 lines
374 B
Elixir
21 lines
374 B
Elixir
defmodule PlausibleWeb.AuthPlug do
|
|
import Plug.Conn
|
|
|
|
def init(options) do
|
|
options
|
|
end
|
|
|
|
def call(conn, _opts) do
|
|
case get_session(conn, :current_user_id) do
|
|
nil -> conn
|
|
id ->
|
|
user = Plausible.Auth.find_user_by(id: id)
|
|
if user do
|
|
assign(conn, :current_user, user)
|
|
else
|
|
conn
|
|
end
|
|
end
|
|
end
|
|
end
|