Commit 843c35bb authored by paz's avatar paz

Allow configurable and multiple superadmins.

parent 3708f870
Pipeline #31504 passed with stages
in 3 minutes and 28 seconds
......@@ -8,7 +8,7 @@ class Account < ActiveRecord::Base
end
def superadmin?
self.email == 'root@localhost'
Array(Conf.superadmins).include?(self.email)
end
def subscribed_to?(list)
......
......@@ -15,12 +15,17 @@ defaults: &defaults
port: <%= ENV["SCHLEUDER_API_PORT"] || 4443 %>
tls_fingerprint: <%= ENV["SCHLEUDER_TLS_FINGERPRINT"] %>
api_key: <%= ENV["SCHLEUDER_API_KEY"] %>
superadmins:
- root@localhost
test:
<<: *defaults
api:
tls_fingerprint: <%= ENV["SCHLEUDER_TLS_FINGERPRINT"] || "6062f05f89384e5f2cda7ab3fc4f5af971d1c524187d90d8e3304e5e0ca6f853" %>
api_key: <%= ENV["SCHLEUDER_API_KEY"] || "ii123456789ii" %>
superadmins:
- admin@localhost
- someoneelse@example.net
development:
<<: *defaults
web_hostname: localhost:3000
......
......@@ -33,8 +33,8 @@ describe Account do
end
describe "#superadmin?" do
it "returns true if email address is root@localhost" do
admin_account = create(:account, email: "root@localhost")
it "returns true if email address is included in Conf.superadmins" do
admin_account = create(:account, email: "admin@localhost")
expect(admin_account.superadmin?).to eq true
end
......
......@@ -25,5 +25,9 @@ describe Conf do
ENV["SCHLEUDER_API_PORT"] = nil
Conf.squire.reload!
end
it "allows multiple site admins" do
expect(Conf.superadmins).to eql(['admin@localhost', 'someoneelse@example.net'])
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment