Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule CatcastsBlog.Plugs.RequireAuth do
- import Plug.Conn
- import Phoenix.Controller
- alias CatcastsBlog.Router.Helpers
- def init(_params) do
- end
- def call(conn, _params) do
- if conn.assigns[:user] do
- conn
- else
- conn
- |> put_flash(:error, "You must be logged in.")
- |> redirect(to: Helpers.video_path(conn, :index))
- |> halt()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement