diff options
Diffstat (limited to 'lib/JWebmail/Model/ReadMails')
-rw-r--r-- | lib/JWebmail/Model/ReadMails/MockJSON.pm | 7 | ||||
-rw-r--r-- | lib/JWebmail/Model/ReadMails/Role.pm | 2 |
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/JWebmail/Model/ReadMails/MockJSON.pm b/lib/JWebmail/Model/ReadMails/MockJSON.pm index 7decb7d..345573c 100644 --- a/lib/JWebmail/Model/ReadMails/MockJSON.pm +++ b/lib/JWebmail/Model/ReadMails/MockJSON.pm @@ -6,8 +6,9 @@ use utf8; use List::Util 'sum'; -use Mojo::JSON qw(decode_json); +use Mojo::JSON 'decode_json'; +use Digest::HMAC_MD5 'hmac_md5_hex'; use Role::Tiny::With; use namespace::clean; @@ -51,6 +52,10 @@ sub verify_user { my $self = shift; my $auth = shift; + if ($auth->{challenge}) { + my $res = hmac_md5_hex($auth->{challenge}, VALID_PW); + return $auth->{user} eq VALID_USER && $auth->{password} eq $res; + } return $auth->{user} eq VALID_USER && $auth->{password} eq VALID_PW; } diff --git a/lib/JWebmail/Model/ReadMails/Role.pm b/lib/JWebmail/Model/ReadMails/Role.pm index d6472a1..466e3b0 100644 --- a/lib/JWebmail/Model/ReadMails/Role.pm +++ b/lib/JWebmail/Model/ReadMails/Role.pm @@ -20,7 +20,7 @@ sub Auth { state $AuthCheck = { user => {defined => 1, required => 1}, password => {defined => 1, required => 1}, - challenge => {defined => 1}, + challenge => {}, }; my $self = @_ == 1 ? $_[0] : {@_}; |