From 0e8194ea7bdce46836b4fd19eba70880ab46541b Mon Sep 17 00:00:00 2001
From: erickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Date: Mon, 14 Jun 2010 13:06:51 +0000
Subject: [PATCH] some minor code cleanup of the retrieve user by barcode
 method

git-svn-id: svn://svn.open-ils.org/ILS/trunk@16698 dcc99617-32d9-48b4-a31d-7c20da2025e4
---
 Open-ILS/src/perlmods/OpenILS/Application/Actor.pm | 33 ++++++----------------
 1 file changed, 9 insertions(+), 24 deletions(-)

diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
index a888cfa5a2..36f374f104 100644
--- a/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
+++ b/Open-ILS/src/perlmods/OpenILS/Application/Actor.pm
@@ -1023,31 +1023,17 @@ __PACKAGE__->register_method(
 	api_name	=> "open-ils.actor.user.fleshed.retrieve_by_barcode",);
 
 sub user_retrieve_by_barcode {
-	my($self, $client, $user_session, $barcode) = @_;
+	my($self, $client, $auth, $barcode) = @_;
 
-	$logger->debug("Searching for user with barcode $barcode");
-	my ($user_obj, $evt) = $apputils->checkses($user_session);
-	return $evt if $evt;
-
-	my $card = OpenILS::Application::AppUtils->simple_scalar_request(
-			"open-ils.cstore", 
-			"open-ils.cstore.direct.actor.card.search.atomic",
-			{ barcode => $barcode }
-	);
-
-	if(!$card || !$card->[0]) {
-		return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' );
-	}
-
-	$card = $card->[0];
-	my $user = flesh_user($card->usr(), new_editor(requestor => $user_obj));
-
-	$evt = $U->check_perms($user_obj->id, $user->home_ou, 'VIEW_USER');
-	return $evt if $evt;
+    my $e = new_editor(authtoken => $auth);
+    return $e->event unless $e->checkauth;
 
-	if(!$user) { return OpenILS::Event->new( 'ACTOR_USER_NOT_FOUND' ); }
-	return $user;
+    my $card = $e->search_actor_card({barcode => $barcode})->[0]
+        or return $e->event;
 
+	my $user = flesh_user($card->usr, $e);
+    return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);
+    return $user;
 }
 
 
@@ -1062,8 +1048,7 @@ sub get_user_by_id {
 	my ($self, $client, $auth, $id) = @_;
 	my $e = new_editor(authtoken=>$auth);
 	return $e->event unless $e->checkauth;
-	my $user = $e->retrieve_actor_user($id)
-		or return $e->event;
+	my $user = $e->retrieve_actor_user($id) or return $e->event;
 	return $e->event unless $e->allowed('VIEW_USER', $user->home_ou);	
 	return $user;
 }
-- 
2.11.0