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 |> validate_required([:provider, :uid])
27 |> foreign_key_constraint(:user_id)
28 |> unique_constraint(:uid, name: :registrations_provider_uid_index)
31 def get_by_provider_uid(provider, uid) do
32 Repo.get_by(Registration,
33 provider: to_string(provider),