From 3b89797dea960b0c5dd98b23190b92308ad7c798 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 11 Jul 2018 19:16:13 -0400 Subject: [PATCH] fix compilation error --- lib/forum/auth.ex | 4 +++- lib/forum/util.ex | 2 +- lib/forum_web/controllers/login_controller.ex | 4 +--- lib/forum_web/controllers/thread_controller.ex | 3 +-- lib/forum_web/templates/layout/app.html.eex | 2 +- lib/forum_web/templates/thread/thread.html.eex | 4 +++- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/lib/forum/auth.ex b/lib/forum/auth.ex index 73f7d85..aa7fb11 100644 --- a/lib/forum/auth.ex +++ b/lib/forum/auth.ex @@ -5,6 +5,8 @@ defmodule Forum.Auth do plug(Tesla.Middleware.FormUrlencoded) def authenticate(user, pw) do - post("/", %{user: user, pw: pw}) + {:ok , response} = post("/", %{user: user, pw: pw}) + IO.inspect(response) + Jason.decode!(response.body) end end diff --git a/lib/forum/util.ex b/lib/forum/util.ex index e0d1ba9..931e1c8 100644 --- a/lib/forum/util.ex +++ b/lib/forum/util.ex @@ -49,7 +49,7 @@ defmodule Forum.Util do def pp_time(time) do time |> Timex.local() - |> Timex.Format.DateTime.Formatter.format!("%a %b %e, %Y ~ %I:%M %P", :strftime) + |> Timex.Format.DateTime.Formatter.format!("%b %e, %Y ~ %I:%M %P", :strftime) |> String.downcase() end diff --git a/lib/forum_web/controllers/login_controller.ex b/lib/forum_web/controllers/login_controller.ex index b16b14b..88ed665 100644 --- a/lib/forum_web/controllers/login_controller.ex +++ b/lib/forum_web/controllers/login_controller.ex @@ -10,9 +10,7 @@ defmodule ForumWeb.LoginController do end def authenticate(conn, %{"username" => username, "password" => pw}) do - {:ok, response} = Auth.authenticate(username, pw) - - resp = Jason.decode!(response.body) + resp = Auth.authenticate(username, pw) case resp["authenticated"] do false -> diff --git a/lib/forum_web/controllers/thread_controller.ex b/lib/forum_web/controllers/thread_controller.ex index b1a5c49..027cfb0 100644 --- a/lib/forum_web/controllers/thread_controller.ex +++ b/lib/forum_web/controllers/thread_controller.ex @@ -24,7 +24,6 @@ defmodule ForumWeb.ThreadController do |> Repo.paginate(params) {:ok, response} = Tesla.get("https://tilde.team/~ben/api/") - tagline = response.body render( conn, @@ -32,7 +31,7 @@ defmodule ForumWeb.ThreadController do stickies: stickies, threads: threads, kerosene: kerosene, - tagline: tagline + tagline: response.body ) end diff --git a/lib/forum_web/templates/layout/app.html.eex b/lib/forum_web/templates/layout/app.html.eex index 356cde0..8eb4bc7 100644 --- a/lib/forum_web/templates/layout/app.html.eex +++ b/lib/forum_web/templates/layout/app.html.eex @@ -75,7 +75,7 @@