summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMark Felder <feld@feld.me>2024-09-01 12:26:59 -0400
committerMark Felder <feld@feld.me>2024-09-01 12:27:16 -0400
commit5a1144208d1007af2a2d2279c582adf9d2fa7246 (patch)
tree48e84806a712d481de1731ac8842613492be5415 /lib
parent62856ab18f8992fb73cb27db40bbea9f29b5d1b6 (diff)
downloadpleroma-5a1144208d1007af2a2d2279c582adf9d2fa7246.tar.gz
pleroma-5a1144208d1007af2a2d2279c582adf9d2fa7246.zip
Prevent OAuth App flow from creating duplicate entries
Diffstat (limited to 'lib')
-rw-r--r--lib/pleroma/web/mastodon_api/controllers/app_controller.ex4
1 files changed, 1 insertions, 3 deletions
diff --git a/lib/pleroma/web/mastodon_api/controllers/app_controller.ex b/lib/pleroma/web/mastodon_api/controllers/app_controller.ex
index 844673ae0..e5e8ea8f5 100644
--- a/lib/pleroma/web/mastodon_api/controllers/app_controller.ex
+++ b/lib/pleroma/web/mastodon_api/controllers/app_controller.ex
@@ -33,11 +33,9 @@ defmodule Pleroma.Web.MastodonAPI.AppController do
app_attrs =
params
|> Map.take([:client_name, :redirect_uris, :website])
- |> Map.put(:scopes, scopes)
|> Maps.put_if_present(:user_id, user_id)
- with cs <- App.register_changeset(%App{}, app_attrs),
- {:ok, app} <- Repo.insert(cs) do
+ with {:ok, app} <- App.get_or_make(app_attrs, scopes) do
render(conn, "show.json", app: app)
end
end