Packages

This is a CMS written in Elixir. Aims to be the great open-source ecommerce and/or startup solution for those who are searching for a performance and stability on top of modern technologies like React and Elixir.

Current section

Files

Jump to
lyn web models authorization.ex
Raw

web/models/authorization.ex

defmodule Lyn.Authorization do
use Lyn.Web, :model
schema "authorizations" do
field :provider, :string
field :uid, :string
field :token, :string
field :refresh_token, :string
field :expires_at, :integer
field :password, :string, virtual: true
field :password_confirmation, :string, virtual: true
belongs_to :user, Lyn.User
timestamps
end
@required_fields ~w(provider uid user_id token)
@optional_fields ~w(refresh_token expires_at)
@doc """
Creates a changeset based on the `model` and `params`.
If no params are provided, an invalid changeset is returned
with no validation performed.
"""
def changeset(model, params \\ :empty) do
model
|> cast(params, @required_fields, @optional_fields)
|> foreign_key_constraint(:user_id)
|> unique_constraint(:provider_uid)
end
end