mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-30 14:57:59 +01:00
add user flag to bypass rate limits
This commit is contained in:
parent
fae0827c81
commit
ae3411b7a2
5 changed files with 28 additions and 4 deletions
|
@ -118,6 +118,7 @@ defmodule Philomena.Users.User do
|
|||
field :secondary_role, :string
|
||||
field :hide_default_role, :boolean, default: false
|
||||
field :senior_staff, :boolean, default: false
|
||||
field :bypass_rate_limits, :boolean, default: false
|
||||
|
||||
# For avatar validation/persistence
|
||||
field :avatar_width, :integer, virtual: true
|
||||
|
@ -271,7 +272,7 @@ defmodule Philomena.Users.User do
|
|||
|
||||
def update_changeset(user, attrs, roles) do
|
||||
user
|
||||
|> cast(attrs, [:name, :email, :role, :secondary_role, :hide_default_role, :senior_staff])
|
||||
|> cast(attrs, [:name, :email, :role, :secondary_role, :hide_default_role, :senior_staff, :bypass_rate_limits])
|
||||
|> validate_required([:name, :email, :role])
|
||||
|> validate_inclusion(:role, ["user", "assistant", "moderator", "admin"])
|
||||
|> put_assoc(:roles, roles)
|
||||
|
|
|
@ -43,6 +43,9 @@ defmodule PhilomenaWeb.LimitPlug do
|
|||
is_staff(conn.assigns.current_user) and skip_staff ->
|
||||
conn
|
||||
|
||||
conn.assigns.current_user.bypass_rate_limits ->
|
||||
conn
|
||||
|
||||
conn.assigns.ajax? ->
|
||||
conn
|
||||
|> Controller.put_flash(:error, error)
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
label.table-list__label
|
||||
.table-list__label__text Senior staff:
|
||||
.table-list__label__input = checkbox f, :senior_staff, class: "checkbox"
|
||||
label.table-list__label
|
||||
.table-list__label__text Bypass rate limits:
|
||||
.table-list__label__input = checkbox f, :bypass_rate_limits, class: "checkbox"
|
||||
.table-list__label
|
||||
.table-list__label__text Avatar
|
||||
.table-list__label__input
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
defmodule Philomena.Repo.Migrations.AddBypassRateLimitsToUsers do
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
alter table(:users) do
|
||||
add :bypass_rate_limits, :boolean, default: false
|
||||
end
|
||||
end
|
||||
|
||||
def down do
|
||||
alter table(:users) do
|
||||
remove :bypass_rate_limits
|
||||
end
|
||||
end
|
||||
end
|
|
@ -2,8 +2,8 @@
|
|||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 13.2
|
||||
-- Dumped by pg_dump version 13.2
|
||||
-- Dumped from database version 13.4
|
||||
-- Dumped by pg_dump version 13.4
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
|
@ -1988,7 +1988,8 @@ CREATE TABLE public.users (
|
|||
last_renamed_at timestamp without time zone DEFAULT '1970-01-01 00:00:00'::timestamp without time zone NOT NULL,
|
||||
forced_filter_id bigint,
|
||||
confirmed_at timestamp(0) without time zone,
|
||||
senior_staff boolean DEFAULT false
|
||||
senior_staff boolean DEFAULT false,
|
||||
bypass_rate_limits boolean DEFAULT false
|
||||
);
|
||||
|
||||
|
||||
|
@ -4844,3 +4845,4 @@ INSERT INTO public."schema_migrations" (version) VALUES (20201124224116);
|
|||
INSERT INTO public."schema_migrations" (version) VALUES (20210121200815);
|
||||
INSERT INTO public."schema_migrations" (version) VALUES (20210301012137);
|
||||
INSERT INTO public."schema_migrations" (version) VALUES (20210427022351);
|
||||
INSERT INTO public."schema_migrations" (version) VALUES (20210917190346);
|
||||
|
|
Loading…
Reference in a new issue