-
Guillaume ROUSSE authoredGuillaume ROUSSE authored
App.pm 2.47 KiB
package AccountManager::App;
use Mojo::Base qw(Mojolicious);
use English qw(-no_match_vars);
use Template::Constants qw(:chomp);
use Syntax::Keyword::Try;
use constant {
ACCESSCHECK_VERSION => '1.2.0'
};
sub startup {
my $self = shift;
$self->plugin('INIConfig', { file => $ENV{ACCESS_CHECK_CONFIG} || 'conf/manager.conf' });
$self->plugin(
'TemplateToolkit',
{
name => 'tt2',
template => {
ABSOLUTE => 1,
ENCODING => 'utf8',
PRE_CHOMP => CHOMP_ONE,
PLUGIN_BASE => 'AccountManager::Template::Plugin',
}
}
);
$self->plugin('ClientIP');
my $config = $self->config();
$self->log(
Mojo::Log->new(
path => $config->{logger}->{file},
level => ($config->{logger}->{level} || 'trace')
)
);
my $theme = $config->{setup}->{templates_theme} || 'default';
my $base_templates_dir = $self->home()->child('templates');
my $renderer = $self->renderer();
$renderer->default_handler('tt2');
$renderer->paths([
$base_templates_dir->child('web', $theme),
$base_templates_dir->child('web'),
$base_templates_dir->child('accounts'),
]);
$self->defaults(
app => {
support_url => $config->{app}->{support_url},
support_email => $config->{app}->{support_email},
login_url => $config->{app}->{login_url},
logout_url => $config->{app}->{logout_url},
name => $config->{app}->{name},
version => ACCESSCHECK_VERSION
},
);
my $routes = $self->routes();
$routes->get('/')->to(controller => 'home', action => 'run')->name('home');
$routes->get('/status')->to(controller => 'status', action => 'run')->name('status');
$routes->get('/step1')->to(controller => 'step1', action => 'run')->name('step1');
$routes->get('/step2')->to(controller => 'step2', action => 'run')->name('step2');