diff options
author | Romain d'Alverny <rda@mageia.org> | 2011-07-27 16:53:34 +0000 |
---|---|---|
committer | Romain d'Alverny <rda@mageia.org> | 2011-07-27 16:53:34 +0000 |
commit | c392ddf66dc25dd598a5aae4fd2a4e100d6752f6 (patch) | |
tree | 57c40209085f319dab6b6a45d1574305b5b7dd02 /lib | |
parent | d7a4e2f4d5eade8606945d448f2a5d124b2a3285 (diff) | |
download | identity-c392ddf66dc25dd598a5aae4fd2a4e100d6752f6.tar identity-c392ddf66dc25dd598a5aae4fd2a4e100d6752f6.tar.gz identity-c392ddf66dc25dd598a5aae4fd2a4e100d6752f6.tar.bz2 identity-c392ddf66dc25dd598a5aae4fd2a4e100d6752f6.tar.xz identity-c392ddf66dc25dd598a5aae4fd2a4e100d6752f6.zip |
code layout
Diffstat (limited to 'lib')
-rw-r--r-- | lib/CatDap/Controller/user.pm | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/lib/CatDap/Controller/user.pm b/lib/CatDap/Controller/user.pm index f2171eb..e6cc7a1 100644 --- a/lib/CatDap/Controller/user.pm +++ b/lib/CatDap/Controller/user.pm @@ -87,7 +87,7 @@ sub auto : Private { -cipher => 'Blowfish' ) or die $!; $c->session->{enc_password} = $cipher->encrypt($c->req->param('password') || $c->req->param('key')); - $c->response->cookies->{'key'} = { value => $key, expires => '+10m' }; + $c->response->cookies->{'key'} = { value => $key, expires => '+10m' }; $c->stash(pages => roles2pages($c->user->roles)); $c->session->{dn} = $c->user->ldap_entry->dn; $c->session->{user} = $c->req->param('username'); @@ -103,7 +103,7 @@ sub auto : Private { $password = $cipher->decrypt($c->session->{enc_password}); $c->log->debug("Re-authenticating user " . $c->user->username); $c->authenticate({username => $c->user->username,password => $password}); - $c->res->cookies->{'key'} = {value => $key, expires => '+10m'}; + $c->res->cookies->{'key'} = {value => $key, expires => '+10m'}; $c->stash(pages => roles2pages($c->user->roles)); $c->log->info($@) if $@; @@ -279,29 +279,28 @@ sub password : Local { my ($mesg,$newpass,$cipher); $c->stash(subpages => gensubpages()); if ( not defined $c->req->param('password') or not defined $c->req->param('newpassword1') or not defined $c->req->param('newpassword2')) { - -#if ( not defined $c->req->param('newpassword1') or not defined $c->req->param('newpassword2')) { + #if ( not defined $c->req->param('newpassword1') or not defined $c->req->param('newpassword2')) { $c->detach; } # Re-authenticate to check the user has the right password if (not $c->authenticate({ - 'username' => $c->user->username, - 'password' => $c->req->param('password'), - }) - ) { - $c->stash(errors => [ $c->loc('Password incorrect') ]); - $c->detach; + 'username' => $c->user->username, + 'password' => $c->req->param('password'), + }) + ) { + $c->stash(errors => [ $c->loc('Password incorrect') ]); + $c->detach; } if ($c->req->param('newpassword1') eq $c->req->param('newpassword2')) { $newpass = $c->req->param('newpassword1'); } else { push @{${$c->stash}{'errors'}},$c->loc('New passwords dont match'); - $c->detach; + $c->detach; } my $pp = Net::LDAP::Control::PasswordPolicy->new; $mesg = $c->model('User')->set_password( - #oldpasswd => $c->req->param('password'), + #oldpasswd => $c->req->param('password'), newpasswd => $newpass, control => [ $pp ], ); @@ -319,7 +318,7 @@ sub password : Local { ) or die $!; $c->session->{enc_password} = $cipher->encrypt($newpass); push @{${$c->stash}{'errors'}},"Password change succeeded"; - #$c->res->redirect('/user'); + #$c->res->redirect('/user'); } } @@ -336,17 +335,17 @@ sub firstlogin : Local { username => $c->req->param('username'), password => $c->req->param('key')}) ) { $c->stash(errors => ['An error occurred']); - $c->log->info("Failed to authenticate user in first login: " . $c->req->param('key')); + $c->log->info("Failed to authenticate user in first login: " . $c->req->param('key')); $c->res->redirect('/user'); - } - # cache password for next request with form data + } + # cache password for next request with form data my $keyprefix = $self->get_keyprefix($c); - my $key = Data::UUID->new->create_str(); + my $key = Data::UUID->new->create_str(); $cipher = Crypt::CBC->new( -key => $keyprefix . $key, -cipher => 'Blowfish' ) or die $!; $c->session->{enc_password} = $cipher->encrypt($c->req->param('key')); - $c->response->cookies->{'key'} = { value => $key, expires => '+10m' }; + $c->response->cookies->{'key'} = { value => $key, expires => '+10m' }; $c->detach; } @@ -364,7 +363,7 @@ sub firstlogin : Local { ) or die $!; my $password = $cipher->decrypt($c->session->{enc_password}); $c->authenticate({username => $c->req->param('username'),password => $password}) - or $c->log->info("Authenticating user for first password change failed"); + or $c->log->info("Authenticating user for first password change failed"); my $pp = Net::LDAP::Control::PasswordPolicy->new; $mesg = $c->model('User')->set_password( |