Skip to content

Instantly share code, notes, and snippets.

@shankardevy
Last active August 18, 2017 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shankardevy/69c0f2ba3a172b3cbc5eb84eb0d9ccdf to your computer and use it in GitHub Desktop.
Save shankardevy/69c0f2ba3a172b3cbc5eb84eb0d9ccdf to your computer and use it in GitHub Desktop.
defmodule MangoWeb.Plugs.LoadCustomer do
import Plug.Conn
alias Mango.CRM
def init(_opts), do: nil
def call(conn, _opts) do
customer_id = get_session(conn, :customer_id)
customer = customer_id && CRM.get_customer(customer_id)
assign(conn, :current_customer, customer)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment