[rt-users] Autogenerating a password for requestors
allen+rtlist at crystalfontz.com
allen+rtlist at crystalfontz.com
Thu May 7 13:44:01 EDT 2009
> My bigger goal is to set up RT so that requestors get an email
> notifying them of their ticket id etc aftre creation. If they are new
> users, they should get a autocreated password.
>
> There is a page in the wiki on this
> http://wiki.bestpractical.com/view/AutogeneratedPassword
>
> This works when I submit a ticket via email.
>
> But I wasn't able to get template from AutogeneratedPassword
> to work. I guess, some of the values used in there do not apply to this
> later stage.
I noticed that the Autogeneratepassword template scrip offered in the
wiki works fine at creating and emailing a password to a new user who
just created a ticket by email, but it did not seem to do the same
when a privileged user manually created a ticket in the RT web
interface.
The reason it didn;t is because in that case, the Transaction
CreatorObj is the privileged user, not the new user. Therefore, the
scripted tests that determine whether to set a password fail and the
whole set password script is skipped.
I (think) I fixed this by changing the "Autoreply" Templat script to be like so:
--- begin Autoreply template ---
Greetings,
Your support ticket [{$Ticket->QueueObj->SubjectTag || $rtname}
#{$Ticket->id()}] regarding:
"{$Ticket->Subject()}"
has been created, and a summary appears below.
Please check the history and progress of all your tickets and
communicate with our staff about your issue by logging in to the
web-based ticket system at:
{
*RT::User::GenerateRandomNextChar = \&RT::User::_GenerateRandomNextChar;
# CHANGED NEXT 3 LINES TO TEST REQUESTOR INSTEAD OF CREATOR
# SO THAT WILL EMAIL REQUESTOR A PASSWORD WHEN STAFF CREATES
# THE TICKET IN WEB INTERFACE
#if (($Transaction->CreatorObj->id != $RT::Nobody->id) &&
# (!$Transaction->CreatorObj->Privileged) &&
# ($Transaction->CreatorObj->__Value('Password') eq '*NO-PASSWORD*')
if (($Ticket->Requestors->UserMembersObj->First->Id() != $RT::Nobody->id) &&
(!$Ticket->Requestors->UserMembersObj->First->Privileged) &&
($Ticket->Requestors->UserMembersObj->First->__Value('Password')
eq '*NO-PASSWORD*')
)
{
my $user = RT::User->new($RT::SystemUser);
# $user->Load($Transaction->CreatorObj->Id);
$user->Load($Ticket->Requestors->UserMembersObj->First->Id());
my ($stat, $pass) = $user->SetRandomPassword();
if (!$stat)
{
$OUT .=
"An internal error has occurred. RT was not able to set a password for you.
Please contact your local RT administrator for assistance.";
}
use URI::Escape;
$OUT .= " ". $RT::WebURL."SelfService/?user=".
uri_escape($user->Name)."&pass=". uri_escape($pass)."
Your username and password for the ticket system are:
Username: ".$user->Name."
Password: ".$pass."
You may change the password after you login if you wish.";
}
else
{
$OUT .= " ". $RT::WebURL ."Ticket/Display.html?id=". $Ticket->id();
}
}
This is an automated message. Please do not reply.
Thank you,
{$Ticket->QueueObj->CorrespondAddress()}
-------------------------------------------------------------------------
{$Transaction->Content()}
--- end Autoreply template ---
I don;t know if that is right or proper, but it seems to work.
Allen
More information about the rt-users
mailing list