- def auth_active?(user), do: user.info && !user.info.confirmation_pending
+ def auth_active?(%User{} = user) do
+ (user.info && !user.info.confirmation_pending) ||
+ !Pleroma.Config.get([:instance, :account_activation_required])
+ end
+
+ def superuser?(%User{} = user), do: user.info && User.Info.superuser?(user.info)
def user_info(%User{} = user) do
oneself = if user.local, do: 1, else: 0
def user_info(%User{} = user) do
oneself = if user.local, do: 1, else: 0
- note_count: user_info.note_count,
- follower_count: user_info.follower_count,
- locked: user_info.locked,
- confirmation_pending: user_info.confirmation_pending,
- default_scope: user_info.default_scope
+ note_count: user.info.note_count,
+ follower_count: user.info.follower_count,
+ locked: user.info.locked,
+ confirmation_pending: user.info.confirmation_pending,
+ default_scope: user.info.default_scope
changeset =
struct
|> cast(params, [:bio, :email, :name, :nickname, :password, :password_confirmation])
changeset =
struct
|> cast(params, [:bio, :email, :name, :nickname, :password, :password_confirmation])
|> validate_confirmation(:password)
|> unique_constraint(:email)
|> unique_constraint(:nickname)
|> validate_confirmation(:password)
|> unique_constraint(:email)
|> unique_constraint(:nickname)
|> validate_format(:nickname, local_nickname_regex())
|> validate_format(:email, @email_regex)
|> validate_length(:bio, max: 1000)
|> validate_length(:name, min: 1, max: 100)
|> validate_format(:nickname, local_nickname_regex())
|> validate_format(:email, @email_regex)
|> validate_length(:bio, max: 1000)
|> validate_length(:name, min: 1, max: 100)
@doc "Inserts provided changeset, performs post-registration actions (confirmation email sending etc.)"
def register(%Ecto.Changeset{} = changeset) do
@doc "Inserts provided changeset, performs post-registration actions (confirmation email sending etc.)"
def register(%Ecto.Changeset{} = changeset) do
- with {:ok, user} <- Repo.insert(changeset) do
- {:ok, _} = try_send_confirmation_email(user)
+ with {:ok, user} <- Repo.insert(changeset),
+ {:ok, _} = try_send_confirmation_email(user) do