analytics / lib /plausible /site /google_auth.ex
Leon4gr45's picture
Upload folder using huggingface_hub (part 2)
8da2481 verified
Raw
History Blame Contribute Delete
789 Bytes
defmodule Plausible.Site.GoogleAuth do
@moduledoc """
Struct for storing google auth token info used by search console.
"""
use Ecto.Schema
import Ecto.Changeset
schema "google_auth" do
field :email, :string
field :property, :string
field :refresh_token, :string
field :access_token, :string
field :expires, :naive_datetime
belongs_to :user, Plausible.Auth.User
belongs_to :site, Plausible.Site
timestamps()
end
def changeset(auth, attrs \\ %{}) do
auth
|> cast(attrs, [:refresh_token, :access_token, :expires, :email])
|> validate_required([:refresh_token, :access_token, :expires, :email])
|> unique_constraint(:site)
end
def set_property(auth, attrs \\ %{}) do
auth
|> cast(attrs, [:property])
end
end