Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F21907456
ensure_staff_privileged_plug.ex
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Size
887 B
Referenced Files
None
Subscribers
None
ensure_staff_privileged_plug.ex
View Options
# Pleroma: A lightweight social networking server
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
defmodule
Pleroma.Web.Plugs.EnsureStaffPrivilegedPlug
do
@moduledoc
"""
Ensures staff are privileged enough to do certain tasks.
"""
import
Pleroma.Web.TranslationHelpers
import
Plug.Conn
alias
Pleroma.Config
alias
Pleroma.User
def
init
(
options
)
do
options
end
def
call
(%{
assigns
:
%{
user
:
%
User
{
is_admin
:
true
}}}
=
conn
,
_
),
do
:
conn
def
call
(%{
assigns
:
%{
user
:
%
User
{
is_moderator
:
true
}}}
=
conn
,
_
)
do
if
Config
.
get!
([
:instance
,
:privileged_staff
])
do
conn
else
conn
|>
render_error
(
:forbidden
,
"User is not an admin."
)
|>
halt
()
end
end
def
call
(
conn
,
_
)
do
conn
|>
render_error
(
:forbidden
,
"User is not a staff member."
)
|>
halt
()
end
end
File Metadata
Details
Attached
Mime Type
text/x-ruby
Expires
Sun, Dec 28, 1:41 AM (1 d, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
752418
Default Alt Text
ensure_staff_privileged_plug.ex (887 B)
Attached To
Mode
rPUBE pleroma-upstream
Attached
Detach File
Event Timeline
Log In to Comment