1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Pleroma.Registration do
10 alias Pleroma.Registration
14 schema "registrations" do
15 belongs_to(:user, User, type: Pleroma.FlakeId)
16 field(:provider, :string)
18 field(:info, :map, default: %{})
23 def changeset(registration, params \\ %{}) do
25 |> cast(params, [:user_id, :provider, :uid, :info])
26 |> foreign_key_constraint(:user_id)
27 |> unique_constraint(:uid, name: :registrations_provider_uid_index)
30 def get_by_provider_uid(provider, uid) do
31 Repo.get_by(Registration,
32 provider: to_string(provider),