From: Matt S Trout Date: Sun, 15 Jul 2012 23:10:36 +0000 (+0000) Subject: auditing X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2603aa88629944ad4ba7ea14e25bac1c1ed41578;p=scpubgit%2FApp-EzPz.git auditing --- diff --git a/lib/App/EzPz/Web.pm b/lib/App/EzPz/Web.pm index 26c0051..1fd2f63 100644 --- a/lib/App/EzPz/Web.pm +++ b/lib/App/EzPz/Web.pm @@ -54,28 +54,36 @@ sub dispatch_request { return unless $list; my $error; sub (/) { - $self->_list_dispatchers($list, \$error), + $self->_list_dispatchers($current_user, $list, \$error), sub () { $self->_render_list_page($list, $error) }; }, sub (/deny/|/allow/|/mod/|/digest/) { sub (/*/) { my $sublist = $list->${\$_[1]}; - $self->_list_dispatchers($sublist, \$error), + $self->_list_dispatchers($current_user, $sublist, \$error), sub () { $self->_render_sublist_page($sublist, $error) }; }, }, } } +sub audit_action { + my ($self, $user, $list, $action, $on) = @_; + print STDERR "${user} called ${action} ${on} for ${list}\n"; +} + sub _list_dispatchers { - my ($self, $list, $error_ref) = @_; + my ($self, $current_user, $list, $error_ref) = @_; + my $name = $current_user->username; sub (POST) { sub (%add=) { + $self->audit_action($name, $list->name, 'add', $_[1]); eval { $list->add_member($_[1]); 1 } or ${$error_ref} = $@; return; }, sub (%remove=) { + $self->audit_action($name, $list->name, 'remove', $_[1]); eval { $list->remove_member($_[1]); 1 } or ${$error_ref} = $@; return;