Skip to content

Instantly share code, notes, and snippets.

@voger
Created July 10, 2017 20:47
Show Gist options
  • Save voger/b93e7406d714ed7f8a3463b6b34d6728 to your computer and use it in GitHub Desktop.
Save voger/b93e7406d714ed7f8a3463b6b34d6728 to your computer and use it in GitHub Desktop.
defmodule Qssite.Middleware.RequireAuthenticated do
@behaviour Absinthe.Middleware
@moduledoc """
Middleware to require authenticated user
"""
def call(resolution, config) do
case resolution.context do
%{current_user: _} ->
resolution
_ ->
Absinthe.Resolution.put_result(resolution, {:error, "unauthenticated"})
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment