52 lines
1012 B
Ruby
52 lines
1012 B
Ruby
class Netig
|
|
hash_branch "admin" do |r|
|
|
require_admin!(r)
|
|
|
|
@page_title = "Admin — NETig"
|
|
@page_description = "Interface d'administration de NETig."
|
|
@canonical_url = "https://netig.net/admin"
|
|
|
|
r.is do
|
|
r.get do
|
|
view "admin"
|
|
end
|
|
end
|
|
|
|
r.on "members" do
|
|
r.is do
|
|
r.get do
|
|
@page_title = "Adhérents — Admin — NETig"
|
|
|
|
@members = DB[:members]
|
|
.join(:accounts, id: :account_id)
|
|
.select_all(:members)
|
|
.select_append(Sequel[:accounts][:email].as(:email))
|
|
.order(Sequel[:members][:id])
|
|
.all
|
|
|
|
view "admin/members"
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def require_admin!(r)
|
|
rodauth.require_account
|
|
|
|
admin = DB[:members].where(
|
|
account_id: rodauth.account_id,
|
|
admin: true
|
|
).get(:admin)
|
|
|
|
return if admin
|
|
|
|
r.halt [
|
|
403,
|
|
{ "Content-Type" => "text/plain; charset=utf-8" },
|
|
["Accès interdit."]
|
|
]
|
|
end
|
|
end
|