LP1207396 user stage allows username selection
authorBill Erickson <berick@esilibrary.com>
Tue, 6 Aug 2013 14:10:19 +0000 (10:10 -0400)
committerDan Wells <dbw2@calvin.edu>
Fri, 23 Aug 2013 23:14:22 +0000 (19:14 -0400)
The caller may now pass a value for username.  If unset, it still falls
back to using a uuid.  If the username clashes with an existing staged
username, a USERNAME_EXISTS event is returned.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Stage.pm

index ff60879..8f094b7 100644 (file)
@@ -38,9 +38,13 @@ sub create_user_stage {
 
     my $e = new_editor(xact => 1);
 
-    my $uname = $U->create_uuid_string;
+    my $uname = $user->usrname || $U->create_uuid_string;
     $user->usrname($uname);
 
+    # see if this username is already taken
+    return OpenILS::Event->new('USERNAME_EXISTS') if
+        $e->search_staging_user_stage({usrname => $uname})->[0];
+
     $e->create_staging_user_stage($user) or return $e->die_event;
 
     if($mail_addr) {