diff options
author | Michael Scherer <misc@mageia.org> | 2010-11-24 23:03:07 +0000 |
---|---|---|
committer | Michael Scherer <misc@mageia.org> | 2010-11-24 23:03:07 +0000 |
commit | e54671ded0cd8db9f6d339c6098f74c7c6e486b0 (patch) | |
tree | a64da6a4f8cb2fab2448d9acbebec28a2f9eb50f /lib/CatDap/Controller | |
parent | 2c147a3a8a8a066b6b5d7b3f318c836790dbe317 (diff) | |
download | identity-e54671ded0cd8db9f6d339c6098f74c7c6e486b0.tar identity-e54671ded0cd8db9f6d339c6098f74c7c6e486b0.tar.gz identity-e54671ded0cd8db9f6d339c6098f74c7c6e486b0.tar.bz2 identity-e54671ded0cd8db9f6d339c6098f74c7c6e486b0.tar.xz identity-e54671ded0cd8db9f6d339c6098f74c7c6e486b0.zip |
- factorise the code who deal with ip ( so we can change it at one place for ipv6 support )
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' |