debianize-mobilizon/lib/mobilizon/applications/application_token.ex
Thomas Citharel 2ee329ff7b
Introduce application tokens
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
2023-03-22 09:34:10 +01:00

27 lines
659 B
Elixir

defmodule Mobilizon.Applications.ApplicationToken do
@moduledoc """
Module representing an application token
"""
use Ecto.Schema
import Ecto.Changeset
schema "application_tokens" do
belongs_to(:user, Mobilizon.Users.User)
belongs_to(:application, Mobilizon.Applications.Application)
field(:authorization_code, :string)
timestamps()
end
@required_attrs [:user_id, :application_id]
@optional_attrs [:authorization_code]
@attrs @required_attrs ++ @optional_attrs
@doc false
def changeset(application_token, attrs) do
application_token
|> cast(attrs, @attrs)
|> validate_required(@required_attrs)
end
end