diff options
author | href <href@random.sh> | 2020-07-07 21:39:10 +0200 |
---|---|---|
committer | href <href@random.sh> | 2020-07-07 21:39:51 +0200 |
commit | d6ee134a5957e299c3ad59011df320b3c41e6e61 (patch) | |
tree | 29567e6635466f8a3415a935b3cc8a777019f5bc /lib/lsg_web/controllers/untappd_controller.ex | |
parent | bleh (diff) |
pouet
Diffstat (limited to 'lib/lsg_web/controllers/untappd_controller.ex')
-rw-r--r-- | lib/lsg_web/controllers/untappd_controller.ex | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/lsg_web/controllers/untappd_controller.ex b/lib/lsg_web/controllers/untappd_controller.ex new file mode 100644 index 0000000..1c3ceb1 --- /dev/null +++ b/lib/lsg_web/controllers/untappd_controller.ex @@ -0,0 +1,18 @@ +defmodule LSGWeb.UntappdController do + use LSGWeb, :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 |