diff options
author | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2022-05-01 21:58:10 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de> | 2022-05-01 21:58:10 +0200 |
commit | 883a3c9379de774a3035986e90614decd8626207 (patch) | |
tree | 3e75f3d82f560f446f670faff78c927eacbfa63e /lib/JWebmail.pm | |
parent | 8387d8eb466e1187ee6caeaeb773d67652797731 (diff) |
merged read and raw routes
Diffstat (limited to 'lib/JWebmail.pm')
-rw-r--r-- | lib/JWebmail.pm | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/lib/JWebmail.pm b/lib/JWebmail.pm index 8def434..9899b05 100644 --- a/lib/JWebmail.pm +++ b/lib/JWebmail.pm @@ -1,6 +1,6 @@ package JWebmail v1.2.0; -use Mojo::Base 'Mojolicious'; +use Mojo::Base Mojolicious; use JWebmail::Controller::Webmail; use JWebmail::Model::ReadMails::Role; @@ -8,6 +8,30 @@ use JWebmail::Model::ReadMails::QMailAuthuser; use JWebmail::Model::WriteMails; +sub nest { +} +sub validateConf { + my $self = shift; + + my $conf = $self->config; + my $v = $self->validator->validation->input($conf); + + $v->optional('secret', 'not_empty'); + + $v->optional('i18n'); + $v->required('session')->required('secure')->in(qw(none cram s3d)); + $v->required('defaults')->required('scriptadmin')->like(qr/@/); + my $dev = $v->optional('development'); + $dev->optional('read_mock', 'not_empty'); + $dev->optional('block_writes')->in(0, 1); + + for ($v->failed->@*) { + say "reasons for $_: " , $v->error($_)->@*; + } + $v->is_valid; +} + + sub startup { my $self = shift; @@ -20,6 +44,8 @@ sub startup { push @{$self->plugins->namespaces}, 'JWebmail::Plugin'; $self->plugin('INIConfig'); + #die unless $self->validateConf; + $self->plugin('ServerSideSessionData'); $self->plugin('Helper'); my $i18n_route = $self->plugin('I18N2', $self->config('i18n')); @@ -63,12 +89,11 @@ sub route { $r->get('/logout')->to('Webmail#logout'); my $a = $r->under('/')->to('Webmail#auth'); - $a->get('/home/:folder')->to('Webmail#displayheaders', folder => '')->name('displayheaders'); + $a->get('/home/*folder')->to('Webmail#displayheaders', folder => '')->name('displayheaders'); $a->get('/read/#id' => 'read')->to('Webmail#readmail'); $a->get('/write')->to('Webmail#writemail'); $a->post('/write' => 'send')-> to('Webmail#sendmail'); $a->post('/move')->to('Webmail#move'); - $a->get('/raw/#id')->to('Webmail#raw'); } |