Add `approval_pending` field to User

This commit is contained in:
Alex Gleason 2020-07-12 19:11:30 -05:00
parent 11dd29ef3f
commit a62f17da17
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
3 changed files with 16 additions and 0 deletions

View File

@ -106,6 +106,7 @@ defmodule Pleroma.User do
field(:locked, :boolean, default: false) field(:locked, :boolean, default: false)
field(:confirmation_pending, :boolean, default: false) field(:confirmation_pending, :boolean, default: false)
field(:password_reset_pending, :boolean, default: false) field(:password_reset_pending, :boolean, default: false)
field(:approval_pending, :boolean, default: false)
field(:confirmation_token, :string, default: nil) field(:confirmation_token, :string, default: nil)
field(:default_scope, :string, default: "public") field(:default_scope, :string, default: "public")
field(:domain_blocks, {:array, :string}, default: []) field(:domain_blocks, {:array, :string}, default: [])
@ -262,6 +263,7 @@ def binary_id(%User{} = user), do: binary_id(user.id)
@spec account_status(User.t()) :: account_status() @spec account_status(User.t()) :: account_status()
def account_status(%User{deactivated: true}), do: :deactivated def account_status(%User{deactivated: true}), do: :deactivated
def account_status(%User{password_reset_pending: true}), do: :password_reset_pending def account_status(%User{password_reset_pending: true}), do: :password_reset_pending
def account_status(%User{approval_pending: true}), do: :approval_pending
def account_status(%User{confirmation_pending: true}) do def account_status(%User{confirmation_pending: true}) do
if Config.get([:instance, :account_activation_required]) do if Config.get([:instance, :account_activation_required]) do

View File

@ -0,0 +1,9 @@
defmodule Pleroma.Repo.Migrations.AddApprovalPendingToUsers do
use Ecto.Migration
def change do
alter table(:users) do
add(:approval_pending, :boolean)
end
end
end

View File

@ -1342,6 +1342,11 @@ test "returns :deactivated for deactivated user" do
user = insert(:user, local: true, confirmation_pending: false, deactivated: true) user = insert(:user, local: true, confirmation_pending: false, deactivated: true)
assert User.account_status(user) == :deactivated assert User.account_status(user) == :deactivated
end end
test "returns :approval_pending for unapproved user" do
user = insert(:user, local: true, confirmation_pending: false, approval_pending: true)
assert User.account_status(user) == :approval_pending
end
end end
describe "superuser?/1" do describe "superuser?/1" do