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>
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) {