__PACKAGE__->register_method( method => 'reset_password_by_email', api_name => 'open-ils.actor.user.password.reset.email', signature => { desc => q/Reset a user's password and email the results to the user/, params => [{desc => 'username', type => 'string'}], return => {desc => q/Returns 1 on success, 0 on failure/, type => 'number'} } ); use Email::Send; sub reset_password_by_email { my($self, $conn, $username) = @_; my $e = new_editor(xact=>1); my $user = $e->search_actor_user({usrname => $username})->[0] or return 0; return 0 unless $user->email; my $password =int(rand 10000); $user->passwd($password); $e->update_actor_user($user) or return 0; my $sender = Email::Send->new({mailer => 'SMTP', mailer_args => [Host => 'localhost']}); my $to_addr = $user->email; my $from_addr = 'evergreen@localhost'; my $email = <send($email); if($stat and $stat->type eq 'success') { $e->commit; return 1; } return 0; }