Skip to content

Instantly share code, notes, and snippets.

@itsderek23
Created March 14, 2017 00:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsderek23/38129bd3f390c9a4daf08571c7e91670 to your computer and use it in GitHub Desktop.
Save itsderek23/38129bd3f390c9a4daf08571c7e91670 to your computer and use it in GitHub Desktop.
defmodule EvercamMedia.SnapmailController do
...
def update(conn, %{"id" => snapmail_exid} = params) do
current_user = conn.assigns[:current_user]
with :ok <- authorized(conn, current_user),
{:ok, cameras} <- ensure_cameras_exist("update", conn, params["camera_exids"], current_user),
{:ok, snapmail} <- snapmail_exist(conn, snapmail_exid),
true <- snapmail.user_id == current_user.id
do
# Code truncated for clarity...updates the Snapmail and associated worker
else
false -> render_error(conn, 401, "Unauthorized.")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment