Packages

This is a CMS written in Elixir. Aims to be the great open-source ecommerce and/or startup solution for those who are searching for a performance and stability on top of modern technologies like React and Elixir.

Current section

Files

Jump to
lyn web controllers admin user_controller.ex
Raw

web/controllers/admin/user_controller.ex

defmodule Lyn.Admin.UserController do
use Lyn.Web, :admin_controller
alias Lyn.User
# Make sure that we have a valid token in the :admin area of the session
# We've aliased Guardian.Plug.EnsureAuthenticated in our Lyn.Web.admin_controller macro
plug EnsureAuthenticated, handler: __MODULE__, key: :admin
def index(conn, _params, current_user, _claims) do
users = Repo.all(User)
render conn, "index.html", users: users, current_user: current_user
end
def unauthenticated(conn, _params) do
conn
|> put_flash(:error, "Admin authentication required")
|> redirect(to: admin_login_path(conn, :new))
end
end