Created
July 10, 2017 20:47
-
-
Save voger/b93e7406d714ed7f8a3463b6b34d6728 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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