diff options
Diffstat (limited to 'lib/CatDap/Controller')
-rw-r--r-- | lib/CatDap/Controller/user.pm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/CatDap/Controller/user.pm b/lib/CatDap/Controller/user.pm index 439f86e..1172346 100644 --- a/lib/CatDap/Controller/user.pm +++ b/lib/CatDap/Controller/user.pm @@ -55,7 +55,7 @@ sub auto : Private { my $mesg; my $dn; my @errors; - my $keyprefix = sprintf("%02x%02x%02x",split /\./,$c->req->address); + my $keyprefix = $self->get_keyprefix($c); if (! defined $c->user or not $c->req->cookie('key')) { if (not $c->req->param('password')) { push @errors,$c->loc('Your session has expired'); @@ -112,6 +112,10 @@ sub auto : Private { } +sub get_keyprefix : Private { + my ( $self, $c ) = @_; + return sprintf("%02x%02x%02x",split /\./,$c->req->address); +} =head2 index =cut @@ -286,7 +290,7 @@ sub password : Local { } else { # re-encrypt the new password and forward to user view - my $keyprefix = sprintf("%02x%02x%02x",split /\./,$c->req->address); + my $keyprefix = $self->get_keyprefix($c); my $key = $c->req->cookie('key')->value; $cipher = Crypt::CBC->new( -key => $keyprefix . $key, -cipher => 'Blowfish' @@ -314,7 +318,7 @@ sub firstlogin : Local { $c->res->redirect('/user'); } # cache password for next request with form data - my $keyprefix = sprintf("%02x%02x%02x",split /\./,$c->req->address); + my $keyprefix = $self->get_keyprefix($c); my $key = Data::UUID->new->create_str(); $cipher = Crypt::CBC->new( -key => $keyprefix . $key, -cipher => 'Blowfish' @@ -331,7 +335,7 @@ sub firstlogin : Local { } #Re-authenticate user - my $keyprefix = sprintf("%02x%02x%02x",split /\./,$c->req->address); + my $keyprefix = $self->get_keyprefix($c); my $key = $c->req->cookie('key')->value; $cipher = Crypt::CBC->new( -key => $keyprefix . $key, -cipher => 'Blowfish' |