summaryrefslogtreecommitdiff
path: root/lib/web/controllers/untappd_controller.ex
diff options
context:
space:
mode:
authorJordan Bracco <href@random.sh>2022-12-20 02:19:42 +0000
committerJordan Bracco <href@random.sh>2022-12-20 19:29:41 +0100
commit9958e90eb5eb5a2cc171c40860745e95a96bd429 (patch)
treeb49cdb1d0041b9c0a81a14950d38c0203896f527 /lib/web/controllers/untappd_controller.ex
parentRename to Nola (diff)
Actually do not prefix folders with nola_ refs T77
Diffstat (limited to 'lib/web/controllers/untappd_controller.ex')
-rw-r--r--lib/web/controllers/untappd_controller.ex18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/web/controllers/untappd_controller.ex b/lib/web/controllers/untappd_controller.ex
new file mode 100644
index 0000000..d3a540d
--- /dev/null
+++ b/lib/web/controllers/untappd_controller.ex
@@ -0,0 +1,18 @@
+defmodule NolaWeb.UntappdController do
+ use NolaWeb, :controller
+
+ def callback(conn, %{"code" => code}) do
+ with \
+ {:account, account_id} when is_binary(account_id) <- {:account, get_session(conn, :account)},
+ {:account, account} when not is_nil(account) <- {:account, IRC.Account.get(account_id)},
+ {:ok, auth_token} <- Untappd.auth_callback(code)
+ do
+ IRC.Account.put_meta(account, "untappd-token", auth_token)
+ text(conn, "OK!")
+ else
+ {:account, _} -> text(conn, "Error: account not found")
+ :error -> text(conn, "Error: untappd authentication failed")
+ end
+ end
+
+end