diff options
author | Buchan Milne <buchan@mageia.org> | 2010-11-02 20:29:21 +0000 |
---|---|---|
committer | Buchan Milne <buchan@mageia.org> | 2010-11-02 20:29:21 +0000 |
commit | 7fa312026a6caba28550339fc29edfd790e78fda (patch) | |
tree | c054f6b854a3c6f6cba566b02b3fdd95b91a124c /lib/CatDap/Controller/user.pm | |
parent | 11665d7a97e320fb38fd076da3ad7c62f36a1362 (diff) | |
download | identity-7fa312026a6caba28550339fc29edfd790e78fda.tar identity-7fa312026a6caba28550339fc29edfd790e78fda.tar.gz identity-7fa312026a6caba28550339fc29edfd790e78fda.tar.bz2 identity-7fa312026a6caba28550339fc29edfd790e78fda.tar.xz identity-7fa312026a6caba28550339fc29edfd790e78fda.zip |
Add some CSS themeing, and refactor some template stuff using preprocess
Add missing tempaltes
Diffstat (limited to 'lib/CatDap/Controller/user.pm')
-rw-r--r-- | lib/CatDap/Controller/user.pm | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/lib/CatDap/Controller/user.pm b/lib/CatDap/Controller/user.pm index 0603217..90dbb0e 100644 --- a/lib/CatDap/Controller/user.pm +++ b/lib/CatDap/Controller/user.pm @@ -53,8 +53,8 @@ sub auto : Private { #TODO: ppolicy .... $c->stash(errors => ['Incorrect username or password']); $c->stash(template => 'index.tt'); - $c->forward('/index'); - $c->detach; + #$c->forward('/index'); + $c->detach('/user/login'); } else { #if (defined $c->user->pwdReset) { # $c->res->redirect('/user'); @@ -65,6 +65,7 @@ sub auto : Private { -cipher => 'Blowfish' ) or die $!; $c->session->{enc_password} = $cipher->encrypt($c->req->param('password') || $c->req->param('key')); + $c->stash(pages => roles2pages($c->user->roles)); $c->session->{dn} = $c->user->ldap_entry->dn; $c->session->{user} = $c->req->param('username'); $password = $c->req->param('password') || $c->req->param('key'); @@ -78,6 +79,8 @@ sub auto : Private { $password = $cipher->decrypt($c->session->{enc_password}); $c->log->info("Re-authenticating user " . $c->session->{user}); $c->authenticate({username => $c->session->{user},password => $password}); + + $c->stash(pages => roles2pages($c->user->roles)); $c->log->info($@) if $@; return 1; } @@ -186,6 +189,7 @@ sub index :Path :Args(0) { may => \@may, must => \@must, }); + $c->stash(subpages => gensubpages()); } sub add : Local { @@ -223,8 +227,10 @@ sub delete : Local : Args(2) { sub password : Local { my ( $self, $c) = @_; 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')) { + $c->detach; } if ($c->req->param('newpassword1') eq $c->req->param('newpassword2')) { @@ -318,6 +324,30 @@ sub logout : Local { $c->res->redirect('/'); } +sub roles2pages : Private { + my @roles = @_; + my @pages; + foreach my $role (sort @roles) { + if ($role =~ /^(\w+) ?(\w*) (Admin)s$/) { + my $page = lc("/$3/$1$2"); + push @pages,{ page => lc("/$3/$1$2"), title => "$1 $2 $3"}; + } + } + return \@pages; +} + +sub gensubpages : Private { + my ($type) = @_; + my @subpagenames; + @subpagenames = ( + { page => './', title => "Edit"}, + { page => 'password', title => "Change password"}, + ); + return \@subpagenames; +} + + + =head1 AUTHOR Buchan Milne |