X-Git-Url: http://git.squeep.com/?a=blobdiff_plain;f=lib%2Fpleroma%2Fweb%2Fmastodon_api%2Fcontrollers%2Fauth_controller.ex;h=a9ccaa982dfc5be4f0e370be005441229b971645;hb=63ce25f32c9bd0dfd5a4db9ad14b6b773c9b05a9;hp=93d057a79ef6bbe35877572c6f2cd990e6bca901;hpb=c8e7ace812ef199b6d24013e7d2699daf1b79d55;p=akkoma
diff --git a/lib/pleroma/web/mastodon_api/controllers/auth_controller.ex b/lib/pleroma/web/mastodon_api/controllers/auth_controller.ex
index 93d057a79..a9ccaa982 100644
--- a/lib/pleroma/web/mastodon_api/controllers/auth_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/auth_controller.ex
@@ -1,5 +1,5 @@
# Pleroma: A lightweight social networking server
-# Copyright © 2017-2020 Pleroma Authors
+# Copyright © 2017-2021 Pleroma Authors
# SPDX-License-Identifier: AGPL-3.0-only
defmodule Pleroma.Web.MastodonAPI.AuthController do
@@ -27,7 +27,8 @@ defmodule Pleroma.Web.MastodonAPI.AuthController do
def login(conn, %{"code" => auth_token} = params) do
with {:ok, app} <- local_mastofe_app(),
{:ok, auth} <- Authorization.get_by_token(app, auth_token),
- {:ok, oauth_token} <- Token.exchange_token(app, auth) do
+ %User{} = user <- User.get_cached_by_id(auth.user_id),
+ {:ok, oauth_token} <- Token.get_or_exchange_token(auth, app, user) do
redirect_to =
conn
|> local_mastodon_post_login_path()
@@ -53,7 +54,7 @@ defmodule Pleroma.Web.MastodonAPI.AuthController do
defp redirect_to_oauth_form(conn, _params) do
with {:ok, app} <- local_mastofe_app() do
path =
- o_auth_path(conn, :authorize,
+ Routes.o_auth_path(conn, :authorize,
response_type: "code",
client_id: app.client_id,
redirect_uri: ".",
@@ -90,7 +91,7 @@ defmodule Pleroma.Web.MastodonAPI.AuthController do
defp local_mastodon_post_login_path(conn) do
case get_session(conn, :return_to) do
nil ->
- masto_fe_path(conn, :index, ["getting-started"])
+ Routes.masto_fe_path(conn, :index, ["getting-started"])
return_to ->
delete_session(conn, :return_to)