logo

pleroma

My custom branche(s) on git.pleroma.social/pleroma/pleroma git clone https://hacktivis.me/git/pleroma.git
commit: e6951e7e409471a5fa68bd2387a758d6abb1f728
parent f646b0554fd081c2ea28ba9a45e90033aa06f736
Author: Mark Felder <feld@feld.me>
Date:   Wed, 31 Jul 2024 14:14:31 -0400

Fix User.disclose_client never working correctly

Our test environment cheats by constructing a conn with a custom oauth_access/2 function. This assigns a :token to the conn but due to the way it is constructed it has the :user preloaded. When the OAuth Plug fetches a token it does not preload the user, so the check for user.disclose_client was always nil and assumed to be false.

Preloading the :user ensures the test environment matches reality.

Diffstat:

Achangelog.d/disclose_client.fix1+
Mlib/pleroma/web/plugs/o_auth_plug.ex2+-
2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/changelog.d/disclose_client.fix b/changelog.d/disclose_client.fix @@ -0,0 +1 @@ +Client application data was always missing from the status diff --git a/lib/pleroma/web/plugs/o_auth_plug.ex b/lib/pleroma/web/plugs/o_auth_plug.ex @@ -52,7 +52,7 @@ defmodule Pleroma.Web.Plugs.OAuthPlug do where: t.token == ^token ) - with %Token{user_id: user_id} = token_record <- Repo.one(token_query), + with %Token{user_id: user_id} = token_record <- Repo.one(token_query) |> Repo.preload(:user), false <- is_nil(user_id), %User{} = user <- User.get_cached_by_id(user_id) do {:ok, user, token_record}