26 lines
638 B
Elixir
26 lines
638 B
Elixir
defmodule Web.AuthController do
|
|
use Web, :controller
|
|
|
|
plug Ueberauth
|
|
|
|
def callback(
|
|
%{assigns: %{ueberauth_auth: %{provider: :mastodon} = auth, current_user: user}} = conn,
|
|
_params
|
|
) do
|
|
{:ok, _mastodon_account} =
|
|
Core.Syndication.save_mastodon_account(user, %{
|
|
uid: auth.uid,
|
|
access_token: auth.credentials.token
|
|
})
|
|
|
|
conn
|
|
|> put_flash(:info, "Mastodon account registered")
|
|
|> redirect(to: ~p"/admin/syndication")
|
|
end
|
|
|
|
def callback(conn, _params) do
|
|
conn
|
|
|> put_flash(:error, "Mastodon auth failure")
|
|
|> redirect(to: ~p"/admin/syndication")
|
|
end
|
|
end
|