diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-09-10 15:39:25 +0200 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2023-09-10 15:39:25 +0200 |
commit | 278b76fabf31abe8fc4fbe6ca1c0ad6af830fcb7 (patch) | |
tree | a3ca8baafd3c26b6d8df3840fe92f5e2f2dd0c34 /lib/JWebmail.pm | |
parent | 84186e77461ddeb867fa2944dcbf45217b41b80e (diff) |
added test pam to replace MockMaildir ReadMail implementation
Diffstat (limited to 'lib/JWebmail.pm')
-rw-r--r-- | lib/JWebmail.pm | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/lib/JWebmail.pm b/lib/JWebmail.pm index 993ad59..b829191 100644 --- a/lib/JWebmail.pm +++ b/lib/JWebmail.pm @@ -4,11 +4,10 @@ use Mojo::Base Mojolicious; use Module::Load 'load'; +use JWebmail::Config 'LOGIN_SCHEME'; use JWebmail::Controller::Webmail; -use JWebmail::Model::ReadMails::Role; use JWebmail::Model::ReadMails::QMailAuthuser; use JWebmail::Model::WriteMails; -use JWebmail::Config qw'LOGIN_SCHEME MAILDIR_READER'; sub validateConf { @@ -26,6 +25,9 @@ sub validateConf { getpwnam $conf->{model}{read}{virtual_user} or die; exists $conf->{model}{read}{mailbox_path} or die; -d $conf->{model}{read}{mailbox_path} or die; + exists $conf->{model}{read}{authenticator} or die; + + exists $conf->{model}{write}{sendmail} or die; return 1; } @@ -42,7 +44,7 @@ sub startup { $self->plugin('TOMLConfig'); $self->validateConf; - if (fc LOGIN_SCHEME eq fc 's3d') { + if (fc LOGIN_SCHEME eq fc 'plain') { $self->plugin('ServerSideSessionData'); } $self->plugin('Paginate'); @@ -52,15 +54,11 @@ sub startup { delete $self->config->{secret}; # initialize models - my $read_mails = do { - my $cls = MAILDIR_READER; - eval { load $cls; 1 } || die "Issue for module $cls with: $@"; - $cls->new(($self->config->{model}{read} // {})->%*) - }; - die "given class @{[ ref $read_mails ]} does not ReadMails" - unless $read_mails->DOES('JWebmail::Model::ReadMails::Role'); + my $read_mails = JWebmail::Model::ReadMails::QMailAuthuser->new($self->config->{model}{read}); $self->helper(users => sub { $read_mails }); - $self->helper(send_mail => sub { my ($c, $mail) = @_; JWebmail::Model::WriteMails::sendmail($mail) }); + + my $write = JWebmail::Model::WriteMails->new($self->config->{model}{write}); + $self->helper(send_mail => sub { $write->sendmail($_[1]) }); $self->validator->add_check(mail_line => \&_mail_line); $self->validator->add_filter(non_empty_ul => \&_filter_empty_upload); |