init v0
This commit is contained in:
parent
561ea7543d
commit
43e6b6d318
25 changed files with 8063 additions and 374 deletions
|
|
@ -195,6 +195,31 @@ defmodule ZoeyscomputerWeb.UserAuth do
|
|||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Used for routes that require an admin user.
|
||||
|
||||
Currently used for the `/dev/` routes.
|
||||
"""
|
||||
def require_authenticated_admin_user(conn, _opts) do
|
||||
if conn.assigns[:current_user] do
|
||||
if conn.assigns[:current_user].admin do
|
||||
conn
|
||||
else
|
||||
conn
|
||||
|> put_flash(:error, "You must be an admin to access this page.")
|
||||
|> maybe_store_return_to()
|
||||
|> redirect(to: ~p"/")
|
||||
|> halt()
|
||||
end
|
||||
else
|
||||
conn
|
||||
|> put_flash(:error, "You must log in to access this page.")
|
||||
|> maybe_store_return_to()
|
||||
|> redirect(to: ~p"/users/log_in")
|
||||
|> halt()
|
||||
end
|
||||
end
|
||||
|
||||
@doc """
|
||||
Used for routes that require the user to be authenticated.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue