Created
July 15, 2018 13:31
-
-
Save cybrox/3c15f2966ce417451f3f3cdd36614b6b to your computer and use it in GitHub Desktop.
Blog: Testing Protected Phoenix Controllers - Snippet 1
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
def authenticate_user_token(conn, _opts) do | |
with ["Bearer " <> token] <- get_req_header(conn, "authorization"), | |
{:ok, %{:id => user_id}} <- Token.verify_user_for_token(token), | |
conn_assign_user_details(conn, user_id) | |
else | |
_ -> send_unauthorized_if_not_faked(conn) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment