View Source Plausible.Auth.GracePeriod (Plausible v0.0.1)

This embedded schema stores information about the account locking grace period.

Users are given this 7-day grace period to upgrade their account after outgrowing their subscriptions. The actual account locking happens in background with Plausible.Workers.LockSites.

The grace period can also be manual, without an end date, being controlled manually from the CRM, and not by the background site locker job. This is useful for enterprise subscriptions.

Link to this section Summary

Functions

Returns whether the grace period is still active for a User. Defaults to false if the user is nil or there is no grace period.

Ends an existing grace period by setting users.grace_period.is_over to true. This means the grace period has expired.

Returns whether the grace period has already expired for a User. Defaults to false if the user is nil or there is no grace period.

Removes the grace period from the User completely.

Starts a account locking grace period of 7 days by changing the User struct.

Starts a manual account locking grace period by changing the User struct. Manual locking means the grace period can only be removed manually from the CRM.

Link to this section Types

@type t() :: %Plausible.Auth.GracePeriod{
  allowance_required: non_neg_integer(),
  end_date: Date.t() | nil,
  id: term(),
  is_over: boolean(),
  manual_lock: boolean()
}

Link to this section Functions

@spec active?(Plausible.Auth.User.t()) :: boolean()

Returns whether the grace period is still active for a User. Defaults to false if the user is nil or there is no grace period.

@spec end_changeset(Plausible.Auth.User.t()) :: Ecto.Changeset.t()

Ends an existing grace period by setting users.grace_period.is_over to true. This means the grace period has expired.

@spec expired?(Plausible.Auth.User.t()) :: boolean()

Returns whether the grace period has already expired for a User. Defaults to false if the user is nil or there is no grace period.

@spec remove_changeset(Plausible.Auth.User.t()) :: Ecto.Changeset.t()

Removes the grace period from the User completely.

Link to this function

start_changeset(user, allowance_required)

View Source
@spec start_changeset(Plausible.Auth.User.t(), non_neg_integer()) ::
  Ecto.Changeset.t()

Starts a account locking grace period of 7 days by changing the User struct.

Link to this function

start_manual_lock_changeset(user, allowance_required)

View Source
@spec start_manual_lock_changeset(Plausible.Auth.User.t(), non_neg_integer()) ::
  Ecto.Changeset.t()

Starts a manual account locking grace period by changing the User struct. Manual locking means the grace period can only be removed manually from the CRM.