1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
|