diff options
Diffstat (limited to 'lib/JWebmail/Controller/Webmail.pm')
-rw-r--r-- | lib/JWebmail/Controller/Webmail.pm | 37 |
1 files changed, 29 insertions, 8 deletions
diff --git a/lib/JWebmail/Controller/Webmail.pm b/lib/JWebmail/Controller/Webmail.pm index 7bf083a..b044fc6 100644 --- a/lib/JWebmail/Controller/Webmail.pm +++ b/lib/JWebmail/Controller/Webmail.pm @@ -55,16 +55,13 @@ sub auth { sub _time :prototype(&$$) { - my $code = shift; - my $self = shift; - my $name = shift; + my ($code, $self, $name) = @_; $self->timing->begin($name); - my @res = $code->(); - my $elapsed = $self->timing->elapsed($name); - $self->app->log->debug(sprintf("%s took %fs", $name, $elapsed)); + + $self->app->log->debug(sprintf("[%s] %s took %fs", $self->req->request_id, $name, $elapsed)); return wantarray ? @res : $res[-1]; } @@ -183,7 +180,7 @@ sub displayheaders { } }; my $elapsed = $self->timing->elapsed('user_headers'); - $self->app->log->debug(sprintf("Reading user headers took %fs", $elapsed)); + $self->app->log->debug(sprintf("[%s] Reading user headers took %fs", $self->req->request_id, $elapsed)); $self->stash( v => JWebmail::View::Webmail->new, @@ -296,6 +293,7 @@ sub move { $v->csrf_protect; if ($v->has_error) { + $self->res->code(400); return; } @@ -305,7 +303,6 @@ sub move { my $mm = $self->every_param('mail'); my $folder = $self->param('folder'); - no warnings 'experimental::smartmatch'; die "$folder not valid" unless any { $folder eq $_ } @$folders; $self->users->move($auth, $_, '', $folder) for @$mm; @@ -316,6 +313,30 @@ sub move { } +sub remove { + my $self = shift; + + my $v = $self->validation; + $v->csrf_protect; + $v->required('mail'); + + if ($v->has_error) { + $self->reply->exception('errors in ' . join('', $v->failed->@*)); + return; + } + + my $auth = $self->stash(STS_AUTH); + + my $mm = $self->every_param('mail'); + my $folder = $self->stash('folder'); + + $self->users->remove($auth, $folder, $_) for @$mm; + + $self->res->code(303); + $self->redirect_to('displayheaders'); +} + + ### session password handling use constant { S_PASSWD => 'pw', S_OTP_S3D_PW => 'otp_s3d_pw' }; |