diff options
Diffstat (limited to 'lib/CatDap/Controller/user.pm')
-rw-r--r-- | lib/CatDap/Controller/user.pm | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/CatDap/Controller/user.pm b/lib/CatDap/Controller/user.pm index b3edb32..f2171eb 100644 --- a/lib/CatDap/Controller/user.pm +++ b/lib/CatDap/Controller/user.pm @@ -202,6 +202,7 @@ sub index :Path :Args(0) { next if ($attr eq "objectClass"); next if grep /$attr/,@{${$c->config}{'Controller::User'}{'skip_attrs'}}; my @vals = $entry->get_value($attr); + foreach (@vals) { $_ = Encode::decode_utf8( $_ ); } $attrdef = $schema->attribute($attr) or die ("getting schema failed: $!"); my %valhash = ( name => $attr, @@ -222,6 +223,7 @@ sub index :Path :Args(0) { grep /$attrname/,@attributes or grep /$attrname/,@{${$c->config}{'Controller::User'}{'uneditable_attrs'}} or grep /$attrname/,@{${$c->config}{'Controller::User'}{'skip_attrs'}} or + grep /$attrname/,@{${$c->config}{'Controller::User'}{'editable_attrs'}} and push @may, $attrname; } } @@ -246,7 +248,7 @@ sub add : Local { my $entry = $mesg->entry; $entry->add( $attr => $value); $c->log->info("Adding $attr = $value to user $user"); - $entry->update; + $mesg = $entry->update; push @{${$c->stash}{'errors'}},$mesg->error if $mesg->code; $c->log->info($mesg->error); $c->res->redirect('/user'); @@ -257,16 +259,19 @@ sub delete : Local : Args(2) { my ($mesg,$entry,$user,$userfilter); $user = $c->user->username; $userfilter = $c->user->store->user_filter; - $userfilter =~ s/%s/$c->user->username/g; - $c->log->debug("Searching for user $user"); + $userfilter =~ s/%s/$user/g; + $c->log->debug("Searching for user $user with filter $userfilter"); $mesg = $c->model('User')->search($userfilter); + push @{${$c->stash}{'errors'}},$mesg->error if $mesg->code; + $c->log->info($mesg->error) if $mesg->code; $entry = $mesg->entry; - $c->log->info("Deleting $attrname = $attrvalue from user $user"); + $c->log->info("Deleting $attrname: $attrvalue from dn " . $entry->dn); $entry->delete($attrname => $attrvalue); - $entry->update; + $mesg = $entry->update; push @{${$c->stash}{'errors'}},$mesg->error if $mesg->code; - $c->log->info($mesg->error); - $c->res->redirect('/user'); + $c->log->info("Result of update: " . $mesg->error . "," . $mesg->code) if $mesg->code; + $c->res->redirect('/user') unless $mesg->code; + $c->stash({ attrname => $attrname, attrvalue => $attrvalue}); } sub password : Local { |