Assign token to connection

This commit is contained in:
Martin Kühl 2018-09-18 11:39:06 +02:00
parent 3193423be9
commit c2d592c9c5

View File

@ -18,10 +18,11 @@ def call(conn, _) do
end
with token when not is_nil(token) <- token,
%Token{user_id: user_id} <- Repo.get_by(Token, token: token),
%Token{user_id: user_id} = token <- Repo.get_by(Token, token: token),
%User{} = user <- Repo.get(User, user_id),
false <- !!user.info["deactivated"] do
conn
|> assign(:token, token)
|> assign(:user, user)
else
_ -> conn