LP#1240119 Safe auth token activity logging
authorBill Erickson <berick@esilibrary.com>
Mon, 19 Aug 2013 13:24:17 +0000 (09:24 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Wed, 19 Aug 2015 18:43:47 +0000 (14:43 -0400)
Expand safe token generation to include user ID in the cached data,
which can be retrieved later for activity logging.  Add activity logging
directly to the open-ils.actor.safe_token.home_lib.shortname API.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Josh Stompro <stomproj@larl.org>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm

index bc08fe5..bdc78da 100644 (file)
@@ -2869,12 +2869,13 @@ sub session_safe_token {
 
     $cache ||= OpenSRF::Utils::Cache->new("global", 0);
 
-    # Add more like the following if needed...
+    # add more user fields as needed
     $cache->put_cache(
-        "safe-token-home_lib-shortname-$safe_token",
-        $e->retrieve_actor_org_unit(
-            $e->requestor->home_ou
-        )->shortname,
+        "safe-token-user-$safe_token", {   
+            id => $e->requestor->id, 
+            home_ou_shortname => $e->retrieve_actor_org_unit(
+                $e->requestor->home_ou)->shortname,
+        },
         60 * 60
     );
 
@@ -2890,14 +2891,19 @@ __PACKAGE__->register_method(
         asscociated with a safe token from generated by
         open-ils.actor.session.safe_token.
         @param safe_token Active safe token
+        @param who Optional user activity "ewho" value
     /
 );
 
 sub safe_token_home_lib {
-    my( $self, $conn, $safe_token ) = @_;
-
+    my( $self, $conn, $safe_token, $who ) = @_;
     $cache ||= OpenSRF::Utils::Cache->new("global", 0);
-    return $cache->get_cache( 'safe-token-home_lib-shortname-'. $safe_token );
+
+    my $blob = $cache->get_cache("safe-token-user-$safe_token");
+    return unless $blob;
+
+    $U->log_user_activity($blob->{id}, $who, 'verify');
+    return $blob->{home_ou_shortname};
 }