summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.md2
-rw-r--r--lib/JWebmail/Model/ReadMails/Role.pm33
2 files changed, 30 insertions, 5 deletions
diff --git a/CHANGES.md b/CHANGES.md
index 7e5dda0..42eef5a 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -124,7 +124,7 @@ Current v1.1.0
- [x] made languages in about clickable
- [x] make loading auth data from session easier
- how do you hide stash values?
- - [ ] password is now hidden when stringified
+ - [x] password is now hidden when stringified
- [x] merge read and raw (with content type)
- how does one extract the body functionality? (One does not.)
- [x] refactor templates to make use of link_to
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;