Mark currently accessing token in oauth token management API

This commit is contained in:
Henry Jameson 2026-11-05 16:16:38 +02:00
commit bcc8b1e296
4 changed files with 21 additions and 5 deletions

View file

@ -26,11 +26,11 @@ defmodule Pleroma.Web.OAuth.TokenController do
end
end
def oauth_tokens(%{assigns: %{user: user}} = conn, _params) do
def oauth_tokens(%{assigns: %{user: user, token: current_token}} = conn, _params) do
with oauth_tokens <- Token.get_user_tokens(user) do
conn
|> put_view(TokenView)
|> render("index.json", %{tokens: oauth_tokens})
|> render("index.json", %{tokens: oauth_tokens, token: current_token})
end
end

View file

@ -11,12 +11,13 @@ defmodule Pleroma.Web.OAuth.TokenView do
|> Enum.filter(&Enum.any?/1)
end
def render("show.json", %{token: token_entry}) do
def render("show.json", %{token: token_entry, current_token: current_token}) do
%{
id: token_entry.id,
valid_until: token_entry.valid_until,
app_name: token_entry.app.client_name,
scopes: token_entry.scopes
scopes: token_entry.scopes,
is_current_token: token_entry.id == current_token.id
}
end
end