summaryrefslogtreecommitdiff
path: root/lib/JWebmail
diff options
context:
space:
mode:
authorJannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de>2022-05-01 21:59:28 +0200
committerJannis M. Hoffmann <jannis.hoffmann@rwth-aachen.de>2022-05-01 21:59:28 +0200
commitc94966aac2f16ca7a6f8c4c8988677515b46a45b (patch)
treec9b8c7c115d3bea2b754512dc4c7e123e1d8310a /lib/JWebmail
parent883a3c9379de774a3035986e90614decd8626207 (diff)
hide password when it sits in stash
Diffstat (limited to 'lib/JWebmail')
-rw-r--r--lib/JWebmail/Model/ReadMails/Role.pm33
1 files changed, 29 insertions, 4 deletions
diff --git a/lib/JWebmail/Model/ReadMails/Role.pm b/lib/JWebmail/Model/ReadMails/Role.pm
index 6d41964..3af73ed 100644
--- a/lib/JWebmail/Model/ReadMails/Role.pm
+++ b/lib/JWebmail/Model/ReadMails/Role.pm
@@ -5,19 +5,31 @@ use Params::Check 'check';
use Mojo::Base -role; # load after imports
+package JWebmail::Model::ReadMails::Role::Shadow {
+
+ use overload '""' => sub { '***' };
+
+ sub new { shift; bless \(shift.'') }
+
+ sub show_password { ${shift()} }
+
+}
+
sub Auth {
shift;
state $AuthCheck = {
- user => {required => 1, defined => 1},
- password => {required => 1, defined => 1},
+ user => {defined => 1, required => 1},
+ password => {defined => 1, required => 1},
challenge => {defined => 1},
};
my $self = @_ == 1 ? $_[0] : {@_};
- return check($AuthCheck, $self, 0) || die Params::Check::last_error;
+ my $res = check($AuthCheck, $self, 0) || die Params::Check::last_error;
+ $res->{password} = JWebmail::Model::ReadMails::Role::Shadow->new($res->{password});
+ return $res;
}
-requires(
+my @methods = (
# name:type parmeter of type
# *key key => value
# key=value default argument of value
@@ -34,6 +46,19 @@ requires(
'move', # auth:Auth, mid, folder -> ^ 1
);
+requires(@methods);
+
+around @methods => sub {
+ my $orig = shift;
+ my $safe = $_[1]->{password};
+ $_[1]->{password} = $safe->show_password;
+ my @res;
+ my $succ = eval { @res = $orig->(@_); 1 };
+ $_[1]->{password} = $safe;
+ die $@ unless $succ;
+ return wantarray ? @res : $res[$#res];
+};
+
around read_headers_for => sub {
my $orig = shift;
my $self = shift;