Skip to content

Commit

Permalink
Add system config functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
abeverley committed Oct 7, 2024
1 parent 93e4f67 commit 78d6b47
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
25 changes: 25 additions & 0 deletions lib/Brass.pm
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,31 @@ any ['get', 'post'] => '/config/server/?:id?' => require_role 'config' => sub {
template 'config/server' => $params;
};

any ['get', 'post'] => '/config/site/' => require_role 'config' => sub {

my $schema = schema;

my $config = $schema->resultset('Config')->next
|| $schema->resultset('Config')->new({});

if (body_parameters->get('save'))
{
error __"No permission to update config"
unless user_has_role 'config_write';
$config->smtp_relayhost(body_parameters->get('smtp_relayhost'));
$config->internal_networks(body_parameters->get('internal_networks'));
if (process sub { $config->insert_or_update })
{
forwardHome({ success => "The configuration has been updated successfully" }, "config/site/" );
}
}

template 'config/site' => {
config => $config,
page => 'config/site',
};
};

any ['get', 'post'] => '/config/uad/?:id?' => require_role 'config' => sub {

my $id = param 'id';
Expand Down
2 changes: 1 addition & 1 deletion lib/Brass/Schema.pm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ __PACKAGE__->load_namespaces;
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-10-01 11:03:29
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GqW9kl7MrcAx0vieFGh+cw

our $VERSION = 42;
our $VERSION = 43;

# You can replace this text with custom code or comments, and it will be preserved on regeneration
1;
1 change: 1 addition & 0 deletions views/layouts/main.tt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Config <b class="caret"></b></a>
<ul class="dropdown-menu">
<li [% IF page=="config/server" %]class="active"[% END %]><a href="/config/server">Servers</a></li>
<li [% IF page=="config/site" %]class="active"[% END %]><a href="/config/site/">Site</a></li>
<li [% IF page=="config/uad" %]class="active"[% END %]><a href="/config/uad">UADs</a></li>
<li [% IF page=="config/cert" %]class="active"[% END %]><a href="/config/cert">Certificates</a></li>
<li [% IF page=="config/pwd" %]class="active"[% END %]><a href="/config/pwd">Passwords</a></li>
Expand Down

0 comments on commit 78d6b47

Please sign in to comment.