summaryrefslogtreecommitdiff
path: root/lib/JWebmail/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'lib/JWebmail/Controller')
-rw-r--r--lib/JWebmail/Controller/Webmail.pm47
1 files changed, 24 insertions, 23 deletions
diff --git a/lib/JWebmail/Controller/Webmail.pm b/lib/JWebmail/Controller/Webmail.pm
index cd7b5c7..3566c83 100644
--- a/lib/JWebmail/Controller/Webmail.pm
+++ b/lib/JWebmail/Controller/Webmail.pm
@@ -47,7 +47,7 @@ sub _time :prototype(&$$) {
my @res = $code->();
my $elapsed = $self->timing->elapsed($name);
- $self->app->log->debug("$name took $elapsed seconds");
+ $self->app->log->debug(sprintf("%s took %fs", $name, $elapsed));
return wantarray ? @res : $res[-1];
}
@@ -60,13 +60,14 @@ sub login {
my $user = $v->required('userid')->size(4, 50)->param;
my $passwd = $v->required('password')->size(4, 50)->like(qr/^.+$/)->param; # no new-lines
+ my $auth = $self->users->Auth(user => $user, password => $passwd);
if ($v->has_error) {
$self->res->code(400);
return $self->render(action => 'noaction');
}
- my $valid = _time { $self->users->verify_user($user, $passwd) } $self, 'verify user';
+ my $valid = _time { $self->users->verify_user($auth) } $self, 'verify user';
if ($valid) {
$self->session(S_USER() => $user);
@@ -113,14 +114,13 @@ sub displayheaders {
no warnings 'experimental::smartmatch';
my $self = shift;
- my $auth = AuthReadMails->new(
+ my $auth = $self->users->Auth(
user => $self->session(S_USER),
password => $self->session_passwd,
challenge => $self->app->secrets->[0],
);
my $folders = _time { $self->users->folders($auth) } $self, 'user folders';
- push @$folders, '';
unless ( $self->stash('folder') ~~ $folders ) {
$self->res->code(404);
@@ -146,23 +146,24 @@ sub displayheaders {
my ($start, $end) = $self->paginate($cnt);
$self->timing->begin('user_headers');
- my $headers;
- if ($search) {
- $headers = $self->users->search(
- $auth, $search, $self->stash('folder'),
- );
- }
- else {
- $headers = $self->users->read_headers_for(
- auth => $auth,
- folder => $self->stash('folder'),
- start => $start,
- end => $end,
- sort => $sort,
- );
- }
+ my $headers = do {
+ if ($search) {
+ $self->users->search(
+ $auth, $search, $self->stash('folder'),
+ )
+ }
+ else {
+ $self->users->read_headers_for(
+ $auth,
+ folder => $self->stash('folder'),
+ start => $start,
+ end => $end,
+ sort => $sort,
+ )
+ }
+ };
my $elapsed = $self->timing->elapsed('user_headers');
- $self->app->log->debug("Reading user headers took $elapsed seconds");
+ $self->app->log->debug(sprintf("Reading user headers took %fs", $elapsed));
$self->stash(
msgs => $headers,
@@ -178,7 +179,7 @@ sub readmail {
my $mid = $self->stash('id');
- my $auth = AuthReadMails->new(
+ my $auth = $self->users->Auth(
user => $self->session(S_USER),
password => $self->session_passwd,
challenge => $self->app->secrets->[0],
@@ -257,7 +258,7 @@ sub move {
return;
}
- my $auth = AuthReadMails->new(
+ my $auth = $self->users->Auth(
user => $self->session(S_USER),
password => $self->session_passwd,
challenge => $self->app->secrets->[0],
@@ -283,7 +284,7 @@ sub raw {
my $mid = $self->stash('id');
- my $auth = AuthReadMails->new(
+ my $auth = $self->users->Auth(
user => $self->session(S_USER),
password => $self->session_passwd,
challenge => $self->app->secrets->[0],