daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest May 19th, 2017 38 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. defmodule CatcastsBlog.Plugs.RequireAuth do
  2.   import Plug.Conn
  3.   import Phoenix.Controller
  4.  
  5.   alias CatcastsBlog.Router.Helpers
  6.  
  7.   def init(_params) do
  8.   end
  9.  
  10.   def call(conn, _params) do
  11.     if conn.assigns[:user] do
  12.       conn
  13.     else
  14.       conn
  15.       |> put_flash(:error, "You must be logged in.")
  16.       |> redirect(to: Helpers.video_path(conn, :index))
  17.       |> halt()
  18.     end
  19.   end
  20. end
RAW Paste Data
Top